|
|
|
|
@ -22,20 +22,34 @@ import com.evolute.utils.ui.search.SearchDialog;
|
|
|
|
|
import com.evolute.utils.ui.window.EditorWindow;
|
|
|
|
|
import info.clearthought.layout.TableLayout;
|
|
|
|
|
import info.clearthought.layout.TableLayoutConstraints;
|
|
|
|
|
|
|
|
|
|
import java.awt.Color;
|
|
|
|
|
import java.awt.Dimension;
|
|
|
|
|
import java.awt.event.ItemEvent;
|
|
|
|
|
import java.awt.event.ItemListener;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.Hashtable;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.Vector;
|
|
|
|
|
import javax.swing.BorderFactory;
|
|
|
|
|
import javax.swing.JCheckBox;
|
|
|
|
|
import javax.swing.JComboBox;
|
|
|
|
|
import javax.swing.JLabel;
|
|
|
|
|
import javax.swing.JPanel;
|
|
|
|
|
import javax.swing.JScrollPane;
|
|
|
|
|
import javax.swing.JSeparator;
|
|
|
|
|
import javax.swing.JTabbedPane;
|
|
|
|
|
import javax.swing.JTextArea;
|
|
|
|
|
import javax.swing.JTextField;
|
|
|
|
|
import siprp.clientes.ClientesDataProvider;
|
|
|
|
|
import siprp.clientes.ContactoPanel;
|
|
|
|
|
import siprp.data.ContactoData;
|
|
|
|
|
import siprp.database.cayenne.objects.Prestadores;
|
|
|
|
|
import siprp.database.cayenne.objects.PrtGruposProtocolo;
|
|
|
|
|
import siprp.database.cayenne.providers.MedicinaDAO;
|
|
|
|
|
import siprp.medicina.prestadores.data.PrestadoresData;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@ -44,6 +58,8 @@ import siprp.medicina.prestadores.data.PrestadoresData;
|
|
|
|
|
*/
|
|
|
|
|
public class PrestadoresWindow extends EditorWindow
|
|
|
|
|
{
|
|
|
|
|
private static final long serialVersionUID = 1L;
|
|
|
|
|
|
|
|
|
|
public static final String TITLE = "Prestadores";
|
|
|
|
|
|
|
|
|
|
protected JTextField nomeText;
|
|
|
|
|
@ -58,7 +74,6 @@ public class PrestadoresWindow extends EditorWindow
|
|
|
|
|
protected ContactoPanel contactoPanel;
|
|
|
|
|
protected JTextField contribuinteText;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected PrestadoresDataProvider provider;
|
|
|
|
|
protected ClientesDataProvider clientesProvider;
|
|
|
|
|
|
|
|
|
|
@ -67,22 +82,44 @@ public class PrestadoresWindow extends EditorWindow
|
|
|
|
|
protected PrestadoresData prestador;
|
|
|
|
|
protected Integer gruposProtocolo[];
|
|
|
|
|
|
|
|
|
|
private final JTabbedPane tabbedPane = new JTabbedPane();
|
|
|
|
|
private final JPanel prestadoresPanel = new JPanel();
|
|
|
|
|
private final JPanel analisadoresPanel = new JPanel();
|
|
|
|
|
|
|
|
|
|
private final JLabel labelGrupos = new JLabel( "Grupos:" );
|
|
|
|
|
private final JLabel labelAnalisador = new JLabel( "Analisador:" );
|
|
|
|
|
private final JLabel labelMessage = new JLabel( " " );
|
|
|
|
|
|
|
|
|
|
private final Map<PrtGruposProtocolo, JLabel> mapLabel = new HashMap<PrtGruposProtocolo, JLabel>();
|
|
|
|
|
private final Map<PrtGruposProtocolo, JComboBox> mapComboBox = new HashMap<PrtGruposProtocolo, JComboBox>();
|
|
|
|
|
|
|
|
|
|
private final List<Prestadores> listAnalisadores = new ArrayList<Prestadores>();
|
|
|
|
|
private final List<PrtGruposProtocolo> listGrupos = new ArrayList<PrtGruposProtocolo>();
|
|
|
|
|
|
|
|
|
|
private final MedicinaDAO medicinaCayenneDAO = new MedicinaDAO();
|
|
|
|
|
|
|
|
|
|
/** Creates a new instance of PrestadoresWindow */
|
|
|
|
|
public PrestadoresWindow()
|
|
|
|
|
throws Exception
|
|
|
|
|
public PrestadoresWindow() throws Exception
|
|
|
|
|
{
|
|
|
|
|
super( new int[][]{{ NEW_INDEX, EDIT_INDEX, CANCEL_INDEX, SAVE_INDEX, DELETE_INDEX,
|
|
|
|
|
SELECT_BYNAME_INDEX }} );
|
|
|
|
|
super( new int[][] {
|
|
|
|
|
{
|
|
|
|
|
NEW_INDEX, EDIT_INDEX, CANCEL_INDEX, SAVE_INDEX, DELETE_INDEX, SELECT_BYNAME_INDEX
|
|
|
|
|
}
|
|
|
|
|
} );
|
|
|
|
|
provider = PrestadoresDataProvider.getProvider();
|
|
|
|
|
clientesProvider = (ClientesDataProvider) ClientesDataProvider.getProvider();
|
|
|
|
|
setupComponents();
|
|
|
|
|
setupComponentsHashtable();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void setupComponents()
|
|
|
|
|
throws Exception
|
|
|
|
|
private void setupComponents() throws Exception
|
|
|
|
|
{
|
|
|
|
|
setTitle( TITLE );
|
|
|
|
|
tabbedPane.addTab( "Prestadores", prestadoresPanel );
|
|
|
|
|
tabbedPane.addTab( "Analisadores", analisadoresPanel );
|
|
|
|
|
|
|
|
|
|
setupAnalisadoresTab();
|
|
|
|
|
|
|
|
|
|
JLabel nomeLabel = new JLabel( "Designa\u00e7\u00e3o" );
|
|
|
|
|
nomeText = new JTextField();
|
|
|
|
|
nomeText.setPreferredSize( new Dimension( 500, 20 ) );
|
|
|
|
|
@ -109,8 +146,7 @@ public class PrestadoresWindow extends EditorWindow
|
|
|
|
|
moradaText = new JTextArea();
|
|
|
|
|
moradaText.setLineWrap( true );
|
|
|
|
|
moradaText.setWrapStyleWord( true );
|
|
|
|
|
JScrollPane moradaScroll = new JScrollPane( moradaText, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
|
|
|
|
|
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
|
|
|
|
|
JScrollPane moradaScroll = new JScrollPane( moradaText, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
|
|
|
|
|
moradaScroll.setPreferredSize( new Dimension( 500, 50 ) );
|
|
|
|
|
JLabel codigoPostalLabel = new JLabel( "C\u00f3digo Postal" );
|
|
|
|
|
codigoPostalText = new JTextField();
|
|
|
|
|
@ -123,32 +159,40 @@ public class PrestadoresWindow extends EditorWindow
|
|
|
|
|
contribuinteText = new JTextField();
|
|
|
|
|
contribuinteText.setPreferredSize( new Dimension( 100, 50 ) );
|
|
|
|
|
|
|
|
|
|
double cols[] =
|
|
|
|
|
new double[]{ TableLayout.MINIMUM, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.FILL };
|
|
|
|
|
double rows[] =
|
|
|
|
|
new double[]{ TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM,
|
|
|
|
|
TableLayout.FILL, TableLayout.PREFERRED, TableLayout.PREFERRED,
|
|
|
|
|
TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM };
|
|
|
|
|
double cols[] = new double[] {
|
|
|
|
|
TableLayout.MINIMUM, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.FILL
|
|
|
|
|
};
|
|
|
|
|
double rows[] = new double[] {
|
|
|
|
|
TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.FILL, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM
|
|
|
|
|
};
|
|
|
|
|
TableLayout tableLayout = new TableLayout( cols, rows );
|
|
|
|
|
prestadoresPanel.setLayout( tableLayout );
|
|
|
|
|
|
|
|
|
|
tableLayout = new TableLayout( new double[] {
|
|
|
|
|
TableLayout.FILL
|
|
|
|
|
}, new double[] {
|
|
|
|
|
TableLayout.FILL
|
|
|
|
|
} );
|
|
|
|
|
getContentPane().setLayout( tableLayout );
|
|
|
|
|
getContentPane().add( tabbedPane, new TableLayoutConstraints( 0, 0 ) );
|
|
|
|
|
|
|
|
|
|
getContentPane().add( nomeLabel, new TableLayoutConstraints( 0, 0 ) );
|
|
|
|
|
getContentPane().add( nomeText, new TableLayoutConstraints( 1, 0, 3, 0 ) );
|
|
|
|
|
getContentPane().add( activoCheck, new TableLayoutConstraints( 0, 1, 2, 1 ) );
|
|
|
|
|
getContentPane().add( consultasCheck, new TableLayoutConstraints( 0, 2 ) );
|
|
|
|
|
getContentPane().add( ecdsCheck, new TableLayoutConstraints( 0, 3 ) );
|
|
|
|
|
getContentPane().add( ecdsPanel, new TableLayoutConstraints( 1, 3, 2, 3 ) );
|
|
|
|
|
getContentPane().add( contactoLabel, new TableLayoutConstraints( 0, 4 ) );
|
|
|
|
|
getContentPane().add( contactoPanel, new TableLayoutConstraints( 1, 4, 2, 4 ) );
|
|
|
|
|
getContentPane().add( moradaLabel, new TableLayoutConstraints( 0, 5 ) );
|
|
|
|
|
getContentPane().add( moradaScroll, new TableLayoutConstraints( 1, 5, 3, 5 ) );
|
|
|
|
|
getContentPane().add( codigoPostalLabel, new TableLayoutConstraints( 0, 6 ) );
|
|
|
|
|
getContentPane().add( codigoPostalText, new TableLayoutConstraints( 1, 6 ) );
|
|
|
|
|
getContentPane().add( localidadeCodigoPostalText, new TableLayoutConstraints( 2, 6, 3, 6 ) );
|
|
|
|
|
getContentPane().add( localidadeLabel, new TableLayoutConstraints( 0, 7 ) );
|
|
|
|
|
getContentPane().add( localidadeText, new TableLayoutConstraints( 1, 7, 3, 7 ) );
|
|
|
|
|
getContentPane().add( contribuinteLabel, new TableLayoutConstraints( 0, 8 ) );
|
|
|
|
|
getContentPane().add( contribuinteText, new TableLayoutConstraints( 1, 8 ) );
|
|
|
|
|
prestadoresPanel.add( nomeLabel, new TableLayoutConstraints( 0, 0 ) );
|
|
|
|
|
prestadoresPanel.add( nomeText, new TableLayoutConstraints( 1, 0, 3, 0 ) );
|
|
|
|
|
prestadoresPanel.add( activoCheck, new TableLayoutConstraints( 0, 1, 2, 1 ) );
|
|
|
|
|
prestadoresPanel.add( consultasCheck, new TableLayoutConstraints( 0, 2 ) );
|
|
|
|
|
prestadoresPanel.add( ecdsCheck, new TableLayoutConstraints( 0, 3 ) );
|
|
|
|
|
prestadoresPanel.add( ecdsPanel, new TableLayoutConstraints( 1, 3, 2, 3 ) );
|
|
|
|
|
prestadoresPanel.add( contactoLabel, new TableLayoutConstraints( 0, 4 ) );
|
|
|
|
|
prestadoresPanel.add( contactoPanel, new TableLayoutConstraints( 1, 4, 2, 4 ) );
|
|
|
|
|
prestadoresPanel.add( moradaLabel, new TableLayoutConstraints( 0, 5 ) );
|
|
|
|
|
prestadoresPanel.add( moradaScroll, new TableLayoutConstraints( 1, 5, 3, 5 ) );
|
|
|
|
|
prestadoresPanel.add( codigoPostalLabel, new TableLayoutConstraints( 0, 6 ) );
|
|
|
|
|
prestadoresPanel.add( codigoPostalText, new TableLayoutConstraints( 1, 6 ) );
|
|
|
|
|
prestadoresPanel.add( localidadeCodigoPostalText, new TableLayoutConstraints( 2, 6, 3, 6 ) );
|
|
|
|
|
prestadoresPanel.add( localidadeLabel, new TableLayoutConstraints( 0, 7 ) );
|
|
|
|
|
prestadoresPanel.add( localidadeText, new TableLayoutConstraints( 1, 7, 3, 7 ) );
|
|
|
|
|
prestadoresPanel.add( contribuinteLabel, new TableLayoutConstraints( 0, 8 ) );
|
|
|
|
|
prestadoresPanel.add( contribuinteText, new TableLayoutConstraints( 1, 8 ) );
|
|
|
|
|
pack();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -165,13 +209,11 @@ public class PrestadoresWindow extends EditorWindow
|
|
|
|
|
components.putComponent( PrestadoresData.ACTIVO, activoCheck );
|
|
|
|
|
components.putComponent( PrestadoresData.FAZ_CONSULTAS, consultasCheck );
|
|
|
|
|
components.putComponent( PrestadoresData.FAZ_ECDS, ecdsCheck );
|
|
|
|
|
components.putComponent( PrestadoresData.CONTACTO_ID,
|
|
|
|
|
new JDOControllable( ( JDOProvider )Singleton.getInstance( Singleton.DEFAULT_JDO_PROVIDER ),
|
|
|
|
|
ContactoData.class, new String[]{ ContactoData.ID },
|
|
|
|
|
contactoPanel ) );
|
|
|
|
|
components.putComponent( PrestadoresData.CONTACTO_ID, new JDOControllable( (JDOProvider) Singleton.getInstance( Singleton.DEFAULT_JDO_PROVIDER ), ContactoData.class, new String[] {
|
|
|
|
|
ContactoData.ID
|
|
|
|
|
}, contactoPanel ) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public boolean searchByName()
|
|
|
|
|
{
|
|
|
|
|
SearchDialog search = new SearchDialog( provider );
|
|
|
|
|
@ -186,8 +228,7 @@ public class PrestadoresWindow extends EditorWindow
|
|
|
|
|
prestador = provider.getPrestadorByID( id );
|
|
|
|
|
gruposProtocolo = provider.getGruposProtocoloIDByPrestadorID( id );
|
|
|
|
|
reload( 0 );
|
|
|
|
|
}
|
|
|
|
|
catch( Exception ex )
|
|
|
|
|
} catch( Exception ex )
|
|
|
|
|
{
|
|
|
|
|
DialogException.showExceptionMessage( ex, "Ocorreu um erro a carregar o prestador.", true );
|
|
|
|
|
return false;
|
|
|
|
|
@ -210,8 +251,7 @@ public class PrestadoresWindow extends EditorWindow
|
|
|
|
|
String names[] = (String[]) components.keySet().toArray( new String[0] );
|
|
|
|
|
ComponentController.fill( names, prestador.getHashData(), components );
|
|
|
|
|
ecdsPanel.setSelected( gruposProtocolo );
|
|
|
|
|
}
|
|
|
|
|
catch( Exception ex )
|
|
|
|
|
} catch( Exception ex )
|
|
|
|
|
{
|
|
|
|
|
DialogException.showExceptionMessage( ex, "Erro a carregar dados", true );
|
|
|
|
|
|
|
|
|
|
@ -246,14 +286,128 @@ public class PrestadoresWindow extends EditorWindow
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
provider.savePrestador( prestador );
|
|
|
|
|
provider.setGruposProtocoloForPrestador( ( Integer ) prestador.get( PrestadoresData.ID ),
|
|
|
|
|
gruposProtocolo );
|
|
|
|
|
}
|
|
|
|
|
catch( Exception ex )
|
|
|
|
|
provider.setGruposProtocoloForPrestador( (Integer) prestador.get( PrestadoresData.ID ), gruposProtocolo );
|
|
|
|
|
} catch( Exception ex )
|
|
|
|
|
{
|
|
|
|
|
DialogException.showExceptionMessage( ex, "Erro a guardar dados", true );
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void setupAnalisadoresTab()
|
|
|
|
|
{
|
|
|
|
|
loadAnalisadoresTabData();
|
|
|
|
|
setupAnalisadoresTabLayout();
|
|
|
|
|
setupAnalisadoresTabComponents();
|
|
|
|
|
placeAnalisadoresTabComponents();
|
|
|
|
|
setupAnalisadoresTabListeners();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void loadAnalisadoresTabData()
|
|
|
|
|
{
|
|
|
|
|
clearAnalisadoresTabData();
|
|
|
|
|
listGrupos.addAll( medicinaCayenneDAO.getAllPrtGruposProtocolo() );
|
|
|
|
|
listAnalisadores.addAll( medicinaCayenneDAO.getAllPrestadores() );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void clearAnalisadoresTabData()
|
|
|
|
|
{
|
|
|
|
|
mapComboBox.clear();
|
|
|
|
|
mapLabel.clear();
|
|
|
|
|
listGrupos.clear();
|
|
|
|
|
listAnalisadores.clear();
|
|
|
|
|
shout(null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void setupAnalisadoresTabLayout()
|
|
|
|
|
{
|
|
|
|
|
double[] cols = new double[] {
|
|
|
|
|
TableLayout.FILL, TableLayout.FILL
|
|
|
|
|
};
|
|
|
|
|
double[] rows = new double[1 + listGrupos.size() + 2 ];
|
|
|
|
|
for( int i = 0; i < rows.length; ++i )
|
|
|
|
|
{
|
|
|
|
|
rows[i] = TableLayout.MINIMUM;
|
|
|
|
|
}
|
|
|
|
|
TableLayout layout = new TableLayout( cols, rows );
|
|
|
|
|
layout.setHGap( 5 );
|
|
|
|
|
layout.setVGap( 5 );
|
|
|
|
|
analisadoresPanel.setLayout( layout );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void setupAnalisadoresTabComponents()
|
|
|
|
|
{
|
|
|
|
|
Object[] analisadores = listAnalisadores.toArray();
|
|
|
|
|
for( PrtGruposProtocolo grupo : listGrupos )
|
|
|
|
|
{
|
|
|
|
|
JLabel label = new JLabel( grupo.getDescricao() );
|
|
|
|
|
mapLabel.put( grupo, label );
|
|
|
|
|
JComboBox combo = new JComboBox( analisadores );
|
|
|
|
|
Prestadores analisador = grupo.getToAnalisador();
|
|
|
|
|
combo.setSelectedItem( analisador == null ? Prestadores.prestadorNulo : analisador );
|
|
|
|
|
mapComboBox.put( grupo, combo );
|
|
|
|
|
}
|
|
|
|
|
labelMessage.setForeground( Color.RED.darker().darker() );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void placeAnalisadoresTabComponents()
|
|
|
|
|
{
|
|
|
|
|
analisadoresPanel.add( labelGrupos, new TableLayoutConstraints( 0, 0 ) );
|
|
|
|
|
analisadoresPanel.add( labelAnalisador, new TableLayoutConstraints( 1, 0 ) );
|
|
|
|
|
for( int i = 0; i < listGrupos.size(); ++i )
|
|
|
|
|
{
|
|
|
|
|
PrtGruposProtocolo grupo = listGrupos.get( i );
|
|
|
|
|
JLabel label = mapLabel.get( grupo );
|
|
|
|
|
analisadoresPanel.add( label, new TableLayoutConstraints( 0, i + 1 ) );
|
|
|
|
|
JComboBox combo = mapComboBox.get( grupo );
|
|
|
|
|
analisadoresPanel.add( combo, new TableLayoutConstraints( 1, i + 1 ) );
|
|
|
|
|
}
|
|
|
|
|
int line = listGrupos.size() + 1;
|
|
|
|
|
analisadoresPanel.add( new JSeparator(), new TableLayoutConstraints( 0, line,1,line ) );
|
|
|
|
|
++line;
|
|
|
|
|
analisadoresPanel.add( labelMessage, new TableLayoutConstraints( 0, line,1,line ) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void setupAnalisadoresTabListeners()
|
|
|
|
|
{
|
|
|
|
|
for( PrtGruposProtocolo grupo : listGrupos )
|
|
|
|
|
{
|
|
|
|
|
JComboBox combo = mapComboBox.get( grupo );
|
|
|
|
|
setupListenersFor( combo );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void setupListenersFor( JComboBox combo )
|
|
|
|
|
{
|
|
|
|
|
combo.addItemListener( new ItemListener()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void itemStateChanged( ItemEvent itemEvent )
|
|
|
|
|
{
|
|
|
|
|
if( ItemEvent.SELECTED == itemEvent.getStateChange() )
|
|
|
|
|
{
|
|
|
|
|
JComboBox combo = (JComboBox) itemEvent.getSource();
|
|
|
|
|
for( PrtGruposProtocolo grupo : mapComboBox.keySet() )
|
|
|
|
|
{
|
|
|
|
|
if( mapComboBox.get( grupo ).equals( combo ) )
|
|
|
|
|
{
|
|
|
|
|
Prestadores analisador = (Prestadores) combo.getSelectedItem();
|
|
|
|
|
grupo.setToAnalisador( Prestadores.prestadorNulo.equals( analisador ) ? null : analisador );
|
|
|
|
|
medicinaCayenneDAO.saveObject( grupo );
|
|
|
|
|
shout( "Grupo: " + grupo.getDescricao() + " -> Analisador: " + analisador.getNome() + " (guardado)" );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void shout( String message )
|
|
|
|
|
{
|
|
|
|
|
labelMessage.setText( message == null ? " " : message );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|