forked from Coded/SIPRP
				
			no message
	
		
	
				
					
				
			git-svn-id: https://svn.coded.pt/svn/SIPRP@260 bb69d46d-e84e-40c8-a05a-06db0d633741
							parent
							
								
									330c1f1a09
								
							
						
					
					
						commit
						3adfa6dc1e
					
				| @ -0,0 +1,296 @@ | |||||||
|  | package siprp.medicina; | ||||||
|  | 
 | ||||||
|  | import com.evolute.utils.*; | ||||||
|  | import com.evolute.utils.arrays.*; | ||||||
|  | import com.evolute.utils.data.*; | ||||||
|  | import com.evolute.utils.dataui.*; | ||||||
|  | import com.evolute.utils.db.*; | ||||||
|  | import com.evolute.utils.documents.*; | ||||||
|  | import com.evolute.utils.sql.*; | ||||||
|  | import com.evolute.utils.ui.*; | ||||||
|  | import com.evolute.utils.ui.panel.*; | ||||||
|  | import com.evolute.utils.ui.text.*; | ||||||
|  | import java.awt.*; | ||||||
|  | import java.util.*; | ||||||
|  | import javax.swing.*; | ||||||
|  | import siprp.data.*; | ||||||
|  | 
 | ||||||
|  | public class MarcacaoConsultaPanel | ||||||
|  | 	extends JPanel | ||||||
|  | 	implements ControllableComponent, DataClassAware | ||||||
|  | { | ||||||
|  | 	private siprp.data.MarcacaoTrabalhadorData marcacaoTrabalhadorData; | ||||||
|  | 	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 | ||||||
|  | 	{ | ||||||
|  | 		JComponent MarcacaoConsultaPanel = this; | ||||||
|  | 		emailButton.setMinimumSize( new Dimension( 300, 20 ) ); | ||||||
|  | 		emailButton.setPreferredSize( new Dimension( 200, 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" ) ); | ||||||
|  | 
 | ||||||
|  | 		observacoesTextScroll.setBorder( BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), "Observa\u00e7\u00f5es" ) ); | ||||||
|  | 		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; | ||||||
|  | 		MarcacaoConsultaPanelLayout.setConstraints( observacoesTextScroll, MarcacaoConsultaPanelGBC ); | ||||||
|  | 		MarcacaoConsultaPanel.add( observacoesTextScroll ); | ||||||
|  | 
 | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	private void setupComponentsHashtable() | ||||||
|  | 	{ | ||||||
|  | 		components.putComponent( siprp.data.MarcacaoTrabalhadorData.DATA, dataPanel ); | ||||||
|  | 		components.putComponent( siprp.data.MarcacaoTrabalhadorData.DATA_RELATORIO, dataFichaPanel ); | ||||||
|  | 		components.putComponent( siprp.data.MarcacaoTrabalhadorData.MOTIVO, tipoList ); | ||||||
|  | 		components.putComponent( siprp.data.MarcacaoTrabalhadorData.ESTADO, estadoList ); | ||||||
|  | 		components.putComponent( siprp.data.MarcacaoTrabalhadorData.OBSERVACOES, observacoesText ); | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	public void fill( Object toFill ) | ||||||
|  | 	{ | ||||||
|  | 		clear(); | ||||||
|  | 		if( toFill == null || !( toFill instanceof PropertyObject ) ) | ||||||
|  | 		{ | ||||||
|  | 			return; | ||||||
|  | 		} | ||||||
|  | 		Hashtable data = null; | ||||||
|  | 		if( toFill instanceof PropertyObject ) | ||||||
|  | 		{ | ||||||
|  | 			data = ( (PropertyObject) toFill ).getHashData(); | ||||||
|  | 			if( toFill instanceof siprp.data.MarcacaoTrabalhadorData ) | ||||||
|  | 			{ | ||||||
|  | 				marcacaoTrabalhadorData = (siprp.data.MarcacaoTrabalhadorData) toFill; | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 		else if( toFill instanceof Hashtable ) | ||||||
|  | 		{ | ||||||
|  | 			data = (Hashtable) toFill; | ||||||
|  | 		} | ||||||
|  | 		else | ||||||
|  | 		{ | ||||||
|  | 			return; | ||||||
|  | 		} | ||||||
|  | 		if( marcacaoTrabalhadorData == null ) | ||||||
|  | 		{ | ||||||
|  | 			marcacaoTrabalhadorData = new siprp.data.MarcacaoTrabalhadorData(); | ||||||
|  | 			marcacaoTrabalhadorData.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( marcacaoTrabalhadorData == null ) | ||||||
|  | 		{ | ||||||
|  | 			marcacaoTrabalhadorData = new siprp.data.MarcacaoTrabalhadorData(); | ||||||
|  | 		} | ||||||
|  | 		Hashtable data = marcacaoTrabalhadorData.getHashData(); | ||||||
|  | 		String properties[] = (String[]) components.keySet().toArray( new String[ 0 ] ); | ||||||
|  | 		ComponentController.save( properties, data, components ); | ||||||
|  | 		if( !( marcacaoTrabalhadorData instanceof PropertyObject ) ) | ||||||
|  | 		{ | ||||||
|  | 			return data; | ||||||
|  | 		} | ||||||
|  | 		marcacaoTrabalhadorData.setHashData( data ); | ||||||
|  | 		return marcacaoTrabalhadorData; | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	public void clear() | ||||||
|  | 	{ | ||||||
|  | 		marcacaoTrabalhadorData = 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 siprp.data.MarcacaoTrabalhadorData.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; | ||||||
|  | 	} | ||||||
|  | } | ||||||
| @ -0,0 +1,92 @@ | |||||||
|  | <?xml version="1.0" encoding="UTF-8"?> | ||||||
|  | 
 | ||||||
|  | <!-- | ||||||
|  |     Document   : HolterPanel.xml | ||||||
|  |     Created on : 1 de Outubro de 2004, 11:17 | ||||||
|  |     Author     : fpalma | ||||||
|  |     Description: | ||||||
|  |         Purpose of the document follows. | ||||||
|  | --> | ||||||
|  | 
 | ||||||
|  | <!DOCTYPE UICOMPONENT SYSTEM 'http://evolute.dyndns.tv/dtd/uicomponent.dtd' > | ||||||
|  | <UICOMPONENT DATA_CLASS="siprp.data.MarcacaoTrabalhadorData"> | ||||||
|  | 	<INCLUDE LANGUAGE="JAVA" >siprp.data.*</INCLUDE> | ||||||
|  | 	<PANEL NAME="MarcacaoConsultaPanel" ROW="0" COLUMN="0"> | ||||||
|  | 		<GRID> | ||||||
|  | 			<ROW TYPE="MIN"/> <!--R0--> | ||||||
|  | 			<ROW TYPE="MIN"/> <!--R1--> | ||||||
|  | 			<ROW TYPE="MIN"/> <!--R2--> | ||||||
|  | 			<ROW TYPE="MAX"/> <!--R3--> | ||||||
|  | 			 | ||||||
|  | 			<COL TYPE="MIN" /> <!--C0--> | ||||||
|  | 			<COL TYPE="MAX" /> <!--C1--> | ||||||
|  | 			<COL TYPE="MAX" /> <!--C2--> | ||||||
|  | 		</GRID> | ||||||
|  | 		 | ||||||
|  | 		<!-- ROW 0 --> | ||||||
|  | 		<LABEL NAME="dataLabel" ROW="0" COLUMN="0"> | ||||||
|  | 			<CAPTION> | ||||||
|  | 				Data da consulta | ||||||
|  | 			</CAPTION> | ||||||
|  | 		</LABEL> | ||||||
|  | 		<EDITOR NAME="dataPanel" ROW="0" COLUMN="1" DATA_FIELD="data"> | ||||||
|  | 			<CONTENT TYPE="DATE" /> | ||||||
|  | 		</EDITOR> | ||||||
|  | 		<BUTTON NAME="emailButton" ROW="0" COLUMN="2"> | ||||||
|  | 			<CAPTION> | ||||||
|  | 				Enviar Email | ||||||
|  | 			</CAPTION> | ||||||
|  | 			<SIZE> | ||||||
|  | 				<WIDTH PREFERRED="200" MIN="300" /> | ||||||
|  | 				<HEIGHT PREFERRED="20" MIN="20" /> | ||||||
|  | 			</SIZE> | ||||||
|  | 		</BUTTON> | ||||||
|  | 		 | ||||||
|  | 		<!-- ROW 1 --> | ||||||
|  | 		<LABEL NAME="dataFichaLabel" ROW="1" COLUMN="0"> | ||||||
|  | 			<CAPTION> | ||||||
|  | 				Data da Ficha de Aptid\u00e3o | ||||||
|  | 			</CAPTION> | ||||||
|  | 		</LABEL> | ||||||
|  | 		<EDITOR NAME="dataFichaPanel" ROW="1" COLUMN="1" DATA_FIELD="data_relatorio"> | ||||||
|  | 			<CONTENT TYPE="DATE" /> | ||||||
|  | 		</EDITOR> | ||||||
|  | 		 | ||||||
|  | 		<!-- ROW 2 --> | ||||||
|  | 		<EDITOR NAME="tipoList" ROW="2" COLUMN="0" COLSPAN="2" EDITABLE="FALSE" DATA_FIELD="motivo"> | ||||||
|  | 			<BORDER TYPE="ETCHED">Tipo</BORDER> | ||||||
|  | 			<CONTENT TYPE="INTEGER" ISLIST="TRUE"> | ||||||
|  | 				<ROWS>4</ROWS> | ||||||
|  | 			</CONTENT> | ||||||
|  | 			<LIST_CONTENT HAS_IDS="TRUE" SELECTABLE="TRUE" DISPLAY_COLUMNS="1"> | ||||||
|  | 				<LIST_OPTION OPTION_ID="1" DEFAULT="TRUE">Admiss\u00e3o</LIST_OPTION> | ||||||
|  | 				<LIST_OPTION OPTION_ID="2">Peri\u00f3dico</LIST_OPTION> | ||||||
|  | 				<LIST_OPTION OPTION_ID="5">Peri\u00f3dico inicial</LIST_OPTION> | ||||||
|  | 				<LIST_OPTION OPTION_ID="3">Ocasional</LIST_OPTION> | ||||||
|  | 			</LIST_CONTENT> | ||||||
|  | 		</EDITOR> | ||||||
|  | 		 | ||||||
|  | 		<EDITOR NAME="estadoList" ROW="2" COLUMN="2" EDITABLE="FALSE" DATA_FIELD="estado"> | ||||||
|  | 			<BORDER TYPE="ETCHED">Estado</BORDER> | ||||||
|  | 			<CONTENT TYPE="INTEGER" ISLIST="TRUE"> | ||||||
|  | 				<ROWS>6</ROWS> | ||||||
|  | 			</CONTENT> | ||||||
|  | 			<LIST_CONTENT HAS_IDS="TRUE" SELECTABLE="TRUE" DISPLAY_COLUMNS="1"> | ||||||
|  | 				<LIST_OPTION OPTION_ID="0" DEFAULT="TRUE">Por realizar</LIST_OPTION> | ||||||
|  | 				<LIST_OPTION OPTION_ID="2">Realizada</LIST_OPTION> | ||||||
|  | 				<LIST_OPTION OPTION_ID="3">Desmarcada pelo trabalhador</LIST_OPTION> | ||||||
|  | 				<LIST_OPTION OPTION_ID="4">Desmarcada pela SIPRP</LIST_OPTION> | ||||||
|  | 				<LIST_OPTION OPTION_ID="5">Faltou</LIST_OPTION> | ||||||
|  | 			</LIST_CONTENT> | ||||||
|  | 		</EDITOR> | ||||||
|  | 		 | ||||||
|  | 		<!-- ROW 3 --> | ||||||
|  | 		<EDITOR NAME="observacoesText" ROW="3" COLUMN="0" COLSPAN="3" DATA_FIELD="observacoes"> | ||||||
|  | 			<BORDER TYPE="ETCHED">Observa\u00e7\u00f5es</BORDER> | ||||||
|  | 			<SCROLL/> | ||||||
|  | 			<CONTENT TYPE="CHAR" ACCEPTS_NEGATIVE="FALSE"> | ||||||
|  | 				<ROWS>5</ROWS> | ||||||
|  | 			</CONTENT> | ||||||
|  | 		</EDITOR> | ||||||
|  | 	</PANEL> | ||||||
|  | </UICOMPONENT> | ||||||
| @ -0,0 +1,261 @@ | |||||||
|  | package siprp.medicina; | ||||||
|  | 
 | ||||||
|  | import com.evolute.utils.*; | ||||||
|  | import com.evolute.utils.arrays.*; | ||||||
|  | import com.evolute.utils.data.*; | ||||||
|  | import com.evolute.utils.dataui.*; | ||||||
|  | import com.evolute.utils.db.*; | ||||||
|  | import com.evolute.utils.documents.*; | ||||||
|  | import com.evolute.utils.sql.*; | ||||||
|  | import com.evolute.utils.ui.*; | ||||||
|  | import com.evolute.utils.ui.panel.*; | ||||||
|  | import com.evolute.utils.ui.text.*; | ||||||
|  | import java.awt.*; | ||||||
|  | import java.util.*; | ||||||
|  | import javax.swing.*; | ||||||
|  | import siprp.data.*; | ||||||
|  | 
 | ||||||
|  | public class MarcacaoExamePanel | ||||||
|  | 	extends JPanel | ||||||
|  | 	implements ControllableComponent, DataClassAware | ||||||
|  | { | ||||||
|  | 	private siprp.data.MarcacaoTrabalhadorData marcacaoTrabalhadorData; | ||||||
|  | 	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" ) ); | ||||||
|  | 
 | ||||||
|  | 		observacoesTextScroll.setBorder( BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), "Observa\u00e7\u00f5es" ) ); | ||||||
|  | 		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; | ||||||
|  | 		MarcacaoExamePanelLayout.setConstraints( observacoesTextScroll, MarcacaoExamePanelGBC ); | ||||||
|  | 		MarcacaoExamePanel.add( observacoesTextScroll ); | ||||||
|  | 
 | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	private void setupComponentsHashtable() | ||||||
|  | 	{ | ||||||
|  | 		components.putComponent( siprp.data.MarcacaoTrabalhadorData.DATA, dataPanel ); | ||||||
|  | 		components.putComponent( siprp.data.MarcacaoTrabalhadorData.ESTADO, estadoList ); | ||||||
|  | 		components.putComponent( siprp.data.MarcacaoTrabalhadorData.OBSERVACOES, observacoesText ); | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	public void fill( Object toFill ) | ||||||
|  | 	{ | ||||||
|  | 		clear(); | ||||||
|  | 		if( toFill == null || !( toFill instanceof PropertyObject ) ) | ||||||
|  | 		{ | ||||||
|  | 			return; | ||||||
|  | 		} | ||||||
|  | 		Hashtable data = null; | ||||||
|  | 		if( toFill instanceof PropertyObject ) | ||||||
|  | 		{ | ||||||
|  | 			data = ( (PropertyObject) toFill ).getHashData(); | ||||||
|  | 			if( toFill instanceof siprp.data.MarcacaoTrabalhadorData ) | ||||||
|  | 			{ | ||||||
|  | 				marcacaoTrabalhadorData = (siprp.data.MarcacaoTrabalhadorData) toFill; | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 		else if( toFill instanceof Hashtable ) | ||||||
|  | 		{ | ||||||
|  | 			data = (Hashtable) toFill; | ||||||
|  | 		} | ||||||
|  | 		else | ||||||
|  | 		{ | ||||||
|  | 			return; | ||||||
|  | 		} | ||||||
|  | 		if( marcacaoTrabalhadorData == null ) | ||||||
|  | 		{ | ||||||
|  | 			marcacaoTrabalhadorData = new siprp.data.MarcacaoTrabalhadorData(); | ||||||
|  | 			marcacaoTrabalhadorData.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( marcacaoTrabalhadorData == null ) | ||||||
|  | 		{ | ||||||
|  | 			marcacaoTrabalhadorData = new siprp.data.MarcacaoTrabalhadorData(); | ||||||
|  | 		} | ||||||
|  | 		Hashtable data = marcacaoTrabalhadorData.getHashData(); | ||||||
|  | 		String properties[] = (String[]) components.keySet().toArray( new String[ 0 ] ); | ||||||
|  | 		ComponentController.save( properties, data, components ); | ||||||
|  | 		if( !( marcacaoTrabalhadorData instanceof PropertyObject ) ) | ||||||
|  | 		{ | ||||||
|  | 			return data; | ||||||
|  | 		} | ||||||
|  | 		marcacaoTrabalhadorData.setHashData( data ); | ||||||
|  | 		return marcacaoTrabalhadorData; | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	public void clear() | ||||||
|  | 	{ | ||||||
|  | 		marcacaoTrabalhadorData = 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 siprp.data.MarcacaoTrabalhadorData.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; | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | } | ||||||
| @ -0,0 +1,78 @@ | |||||||
|  | <?xml version="1.0" encoding="UTF-8"?> | ||||||
|  | 
 | ||||||
|  | <!-- | ||||||
|  |     Document   : HolterPanel.xml | ||||||
|  |     Created on : 1 de Outubro de 2004, 11:17 | ||||||
|  |     Author     : fpalma | ||||||
|  |     Description: | ||||||
|  |         Purpose of the document follows. | ||||||
|  | --> | ||||||
|  | 
 | ||||||
|  | <!DOCTYPE UICOMPONENT SYSTEM 'http://evolute.dyndns.tv/dtd/uicomponent.dtd' > | ||||||
|  | <UICOMPONENT DATA_CLASS="siprp.data.MarcacaoTrabalhadorData"> | ||||||
|  | 	<INCLUDE LANGUAGE="JAVA" >siprp.data.*</INCLUDE> | ||||||
|  | 	<PANEL NAME="MarcacaoExamePanel" ROW="0" COLUMN="0"> | ||||||
|  | 		<GRID> | ||||||
|  | 			<ROW TYPE="MIN"/> <!--R0--> | ||||||
|  | 			<ROW TYPE="MIN"/> <!--R1--> | ||||||
|  | 			<ROW TYPE="MAX"/> <!--R2--> | ||||||
|  | 			 | ||||||
|  | 			<COL TYPE="MIN" /> <!--C0--> | ||||||
|  | 			<COL TYPE="MAX" /> <!--C1--> | ||||||
|  | 			<COL TYPE="MAX" /> <!--C2--> | ||||||
|  | 		</GRID> | ||||||
|  | 		 | ||||||
|  | 		<!-- ROW 0 --> | ||||||
|  | 		<LABEL NAME="dataLabel" ROW="0" COLUMN="0"> | ||||||
|  | 			<CAPTION> | ||||||
|  | 				Data dos Exames | ||||||
|  | 			</CAPTION> | ||||||
|  | 		</LABEL> | ||||||
|  | 		<EDITOR NAME="dataPanel" ROW="0" COLUMN="1" DATA_FIELD="data"> | ||||||
|  | 			<CONTENT TYPE="DATE" /> | ||||||
|  | 		</EDITOR> | ||||||
|  | 		<BUTTON NAME="emailButton" ROW="0" COLUMN="2"> | ||||||
|  | 			<CAPTION> | ||||||
|  | 				Enviar Email | ||||||
|  | 			</CAPTION> | ||||||
|  | 			<SIZE> | ||||||
|  | 				<WIDTH PREFERRED="200" MIN="300" /> | ||||||
|  | 				<HEIGHT PREFERRED="20" MIN="20" /> | ||||||
|  | 			</SIZE> | ||||||
|  | 		</BUTTON> | ||||||
|  | 		 | ||||||
|  | 		<!-- ROW 1 --> | ||||||
|  | 		<PANEL NAME="detalhesPanel" ROW="1" COLUMN="0" COLSPAN="2"> | ||||||
|  | 			<BORDER TYPE="ETCHED">Detalhes</BORDER> | ||||||
|  | 			<GRID> | ||||||
|  | 				<ROW TYPE="MAX"/> <!--R0--> | ||||||
|  | 
 | ||||||
|  | 				<COL TYPE="MAX" /> <!--C0--> | ||||||
|  | 			</GRID> | ||||||
|  | 		</PANEL> | ||||||
|  | 		 | ||||||
|  | 		<EDITOR NAME="estadoList" ROW="1" COLUMN="2" EDITABLE="FALSE" DATA_FIELD="estado"> | ||||||
|  | 			<BORDER TYPE="ETCHED">Estado</BORDER> | ||||||
|  | 			<CONTENT TYPE="INTEGER" ISLIST="TRUE"> | ||||||
|  | 				<ROWS>6</ROWS> | ||||||
|  | 			</CONTENT> | ||||||
|  | 			<LIST_CONTENT HAS_IDS="TRUE" SELECTABLE="TRUE" DISPLAY_COLUMNS="1"> | ||||||
|  | 				<LIST_OPTION OPTION_ID="0" DEFAULT="TRUE">Por realizar</LIST_OPTION> | ||||||
|  | 				<LIST_OPTION OPTION_ID="1">Parcialmente realizados</LIST_OPTION> | ||||||
|  | 				<LIST_OPTION OPTION_ID="2">Realizados</LIST_OPTION> | ||||||
|  | 				<LIST_OPTION OPTION_ID="3">Desmarcados pelo trabalhador</LIST_OPTION> | ||||||
|  | 				<LIST_OPTION OPTION_ID="4">Desmarcados pela SIPRP</LIST_OPTION> | ||||||
|  | 				<LIST_OPTION OPTION_ID="5">Faltou</LIST_OPTION> | ||||||
|  | 			</LIST_CONTENT> | ||||||
|  | 		</EDITOR> | ||||||
|  | 		 | ||||||
|  | 		<!-- ROW 2 --> | ||||||
|  | 		<EDITOR NAME="observacoesText" ROW="2" COLUMN="0" COLSPAN="3" DATA_FIELD="observacoes"> | ||||||
|  | 			<BORDER TYPE="ETCHED">Observa\u00e7\u00f5es</BORDER> | ||||||
|  | 			<SCROLL/> | ||||||
|  | 			<CONTENT TYPE="CHAR" ACCEPTS_NEGATIVE="FALSE"> | ||||||
|  | 				<ROWS>5</ROWS> | ||||||
|  | 			</CONTENT> | ||||||
|  | 		</EDITOR> | ||||||
|  | 	</PANEL> | ||||||
|  | </UICOMPONENT> | ||||||
| @ -0,0 +1,93 @@ | |||||||
|  | /* | ||||||
|  |  * 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.*; | ||||||
|  | 
 | ||||||
|  | import com.evolute.utils.*; | ||||||
|  | import com.evolute.utils.jdo.*; | ||||||
|  | 
 | ||||||
|  | import siprp.data.*; | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * 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(); | ||||||
|  | 		JDOProvider JDO = ( JDOProvider ) Singleton.getInstance( Singleton.DEFAULT_JDO_PROVIDER ); | ||||||
|  | 		TrabalhadorData trabalhador = (TrabalhadorData)JDO.load( TrabalhadorData.class, trabalhadorID ); | ||||||
|  | 		 | ||||||
|  | 		idCorrente = provider.getConsultaIDByTrabalhadorMotivoAndDate( trabalhadorID, motivoCorrente, dataCorrente ); | ||||||
|  | 		MarcacaoTrabalhadorData consultaCorrente; | ||||||
|  | 		if( idCorrente == null ) | ||||||
|  | 		{ | ||||||
|  | 			consultaCorrente = new MarcacaoTrabalhadorData(); | ||||||
|  | 			consultaCorrente.set( MarcacaoTrabalhadorData.TRABALHADOR, trabalhador ); | ||||||
|  | 			consultaCorrente.set( MarcacaoTrabalhadorData.TIPO, new Integer( MarcacaoTrabalhadorData.TIPO_CONSULTA ) ); | ||||||
|  | 			consultaCorrente.set( Marcacao.DATA, dataCorrente ); | ||||||
|  | 			consultaCorrente.set( MarcacaoTrabalhadorData.MOTIVO, motivoCorrente ); | ||||||
|  | 		} | ||||||
|  | 		else | ||||||
|  | 		{ | ||||||
|  | 			consultaCorrente = ( MarcacaoTrabalhadorData ) JDO.load( MarcacaoTrabalhadorData.class, idCorrente ); | ||||||
|  | 		} | ||||||
|  | 		consultaCorrente.set( Marcacao.REALIZADA, "y" ); | ||||||
|  | 		consultaCorrente.set( MarcacaoTrabalhadorData.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 ); | ||||||
|  | 			MarcacaoTrabalhadorData consultaSeguinte; | ||||||
|  | 			if( idSeguinte == null ) | ||||||
|  | 			{ | ||||||
|  | 				consultaSeguinte = new MarcacaoTrabalhadorData(); | ||||||
|  | 				consultaSeguinte.set( MarcacaoTrabalhadorData.TRABALHADOR, trabalhador ); | ||||||
|  | 				consultaSeguinte.set( MarcacaoTrabalhadorData.TIPO, new Integer( MarcacaoTrabalhadorData.TIPO_CONSULTA ) ); | ||||||
|  | 				consultaSeguinte.set( MarcacaoTrabalhadorData.MOTIVO, motivoSeguinte ); | ||||||
|  | 				consultaSeguinte.set( Marcacao.REALIZADA, "y" ); | ||||||
|  | 				consultaSeguinte.set( MarcacaoTrabalhadorData.ESTADO, new Integer( siprp.medicina.MedicinaDataProvider.ESTADO_POR_REALIZAR ) ); | ||||||
|  | 			} | ||||||
|  | 			else | ||||||
|  | 			{ | ||||||
|  | 				consultaSeguinte = ( MarcacaoTrabalhadorData ) JDO.load( MarcacaoTrabalhadorData.class, idSeguinte ); | ||||||
|  | 			} | ||||||
|  | 			consultaSeguinte.set( Marcacao.DATA, dataSeguinte ); | ||||||
|  | 			consultaSeguinte.save(); | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | } | ||||||
| @ -0,0 +1,349 @@ | |||||||
|  | /* | ||||||
|  |  * 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.*; | ||||||
|  | 
 | ||||||
|  | import com.evolute.utils.*; | ||||||
|  | import com.evolute.utils.arrays.*; | ||||||
|  | import com.evolute.utils.data.*; | ||||||
|  | import com.evolute.utils.db.*; | ||||||
|  | import com.evolute.utils.metadb.*; | ||||||
|  | import com.evolute.utils.sql.*; | ||||||
|  | import com.evolute.utils.strings.*; | ||||||
|  | import com.evolute.utils.tables.*; | ||||||
|  | 
 | ||||||
|  | import siprp.*; | ||||||
|  | import siprp.data.*; | ||||||
|  | /** | ||||||
|  |  * | ||||||
|  |  * @author fpalma | ||||||
|  |  */ | ||||||
|  | public class MedicinaDataProvider extends MetaProvider | ||||||
|  | { | ||||||
|  | 	public static final int  ESTADO_POR_REALIZAR = 0; | ||||||
|  | 	public static final int  ESTADO_PARCIALMENTE_REALIZADO = 1; | ||||||
|  | 	public static final int  ESTADO_REALIZADO = 2; | ||||||
|  | 	public static final int  ESTADO_DESMARCADO_TRABALHADOR = 3; | ||||||
|  | 	public static final int  ESTADO_DESMARCADO_EMPRESA = 4; | ||||||
|  | 	public static final int  ESTADO_FALTOU = 5; | ||||||
|  | 
 | ||||||
|  | 	public static final String TIPOS_CONSULTAS[] =  | ||||||
|  | 		new String[]{ "", "Admiss\u00e3o", "Peri\u00f3dico", "Ocasional", "", "Peri\u00f3dico inicial" }; | ||||||
|  | 	 | ||||||
|  | 	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; | ||||||
|  | 	private final Executer executer; | ||||||
|  | 	 | ||||||
|  | 	/** 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 < ids.length; n++ ) | ||||||
|  | 		{ | ||||||
|  | 			ids[ n ] = ( Integer ) array.get( n, 0 ); | ||||||
|  | 		} | ||||||
|  | 		return ids; | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	public void deleteDetalhesRealziadosForMarcacao( 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 | ||||||
|  | 	{ | ||||||
|  | 		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" ).isEqual( motivo ) ) ); | ||||||
|  | 		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; | ||||||
|  | 	} | ||||||
|  | } | ||||||
| @ -0,0 +1,254 @@ | |||||||
|  | /* | ||||||
|  |  * 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.*; | ||||||
|  | import javax.swing.*; | ||||||
|  | import javax.swing.event.*; | ||||||
|  | import java.util.*; | ||||||
|  | 
 | ||||||
|  | import com.evolute.utils.*; | ||||||
|  | import com.evolute.utils.dataui.*; | ||||||
|  | import com.evolute.utils.tables.*; | ||||||
|  | import com.evolute.utils.ui.*; | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * | ||||||
|  |  * @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.5; | ||||||
|  | 		constraints.weighty = 0.5; | ||||||
|  | 		 | ||||||
|  | 		gridbag.setConstraints( empresasScroll, constraints ); | ||||||
|  | 		 | ||||||
|  | 		constraints.gridwidth = GridBagConstraints.REMAINDER; | ||||||
|  | 		gridbag.setConstraints( estabelecimentosScroll, constraints ); | ||||||
|  | 		 | ||||||
|  | 		constraints.weightx = 1; | ||||||
|  | 		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 ); | ||||||
|  | 	} | ||||||
|  | } | ||||||
| @ -0,0 +1,686 @@ | |||||||
|  | /* | ||||||
|  |  * 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.*; | ||||||
|  | import java.awt.event.*; | ||||||
|  | import javax.swing.*; | ||||||
|  | import javax.swing.event.*; | ||||||
|  | import java.text.*; | ||||||
|  | import java.util.*; | ||||||
|  | 
 | ||||||
|  | import com.evolute.utils.*; | ||||||
|  | import com.evolute.utils.arrays.*; | ||||||
|  | import com.evolute.utils.data.*; | ||||||
|  | import com.evolute.utils.jdo.*; | ||||||
|  | import com.evolute.utils.ui.*; | ||||||
|  | import com.evolute.utils.ui.panel.*; | ||||||
|  | import com.evolute.utils.ui.search.*; | ||||||
|  | import com.evolute.utils.ui.text.*; | ||||||
|  | import com.evolute.utils.ui.window.*; | ||||||
|  | 
 | ||||||
|  | import siprp.*; | ||||||
|  | import siprp.clientes.*; | ||||||
|  | import siprp.data.*; | ||||||
|  | /** | ||||||
|  |  * | ||||||
|  |  * @author fpalma | ||||||
|  |  */ | ||||||
|  | public class MedicinaWindow extends TabbedWindow | ||||||
|  | 		implements ActionListener, ListSelectionListener | ||||||
|  | { | ||||||
|  | 	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 JDOProvider JDO; | ||||||
|  | 	protected SIPRPTracker 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 TrabalhadorData 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 = ( JDOProvider ) Singleton.getInstance( Singleton.DEFAULT_JDO_PROVIDER ); | ||||||
|  | 		setupComponents(); | ||||||
|  | 		setExtendedState(getExtendedState() | MAXIMIZED_BOTH); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	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: | ||||||
|  | 				MarcacaoTrabalhadorData exame = ( MarcacaoTrabalhadorData ) marcacaoExamePanel.save(); | ||||||
|  | 				data = ( Date ) exame.get( MarcacaoTrabalhadorData.DATA ); | ||||||
|  | 				if( data == null ) | ||||||
|  | 				{ | ||||||
|  | 					JOptionPane.showMessageDialog( this, "Tem de preencher uma data para os exames.", | ||||||
|  | 						"Erro", JOptionPane.ERROR_MESSAGE ); | ||||||
|  | 					return false; | ||||||
|  | 				} | ||||||
|  | 				exame.set( MarcacaoTrabalhadorData.TIPO,  | ||||||
|  | 							new Integer( Marcacao.TIPO_MARCACAO_TRABALHADOR_EXAMES ) ); | ||||||
|  | 				exame.set( MarcacaoTrabalhadorData.TRABALHADOR, trabalhador );	 | ||||||
|  | 				try | ||||||
|  | 				{ | ||||||
|  | 					exame.set( MarcacaoTrabalhadorData.REALIZADA, | ||||||
|  | 								( ( Integer )exame.get( MarcacaoTrabalhadorData.ESTADO ) ).intValue() == | ||||||
|  | 									provider.ESTADO_REALIZADO ? "y" : "n" ); | ||||||
|  | 					exame.save(); | ||||||
|  | 					Integer exameID = ( Integer ) exame.get( MarcacaoTrabalhadorData.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: | ||||||
|  | 				MarcacaoTrabalhadorData consulta = ( MarcacaoTrabalhadorData ) marcacaoConsultaPanel.save(); | ||||||
|  | 				data = ( Date ) consulta.get( MarcacaoTrabalhadorData.DATA ); | ||||||
|  | 				if( data == null ) | ||||||
|  | 				{ | ||||||
|  | 					JOptionPane.showMessageDialog( this, "Tem de preencher uma data para a consulta.", | ||||||
|  | 						"Erro", JOptionPane.ERROR_MESSAGE ); | ||||||
|  | 					return false; | ||||||
|  | 				} | ||||||
|  | 				consulta.set( MarcacaoTrabalhadorData.TIPO,  | ||||||
|  | 								new Integer( Marcacao.TIPO_MARCACAO_TRABALHADOR_CONSULTA ) ); | ||||||
|  | 				consulta.set( MarcacaoTrabalhadorData.TRABALHADOR, trabalhador );	 | ||||||
|  | 				try | ||||||
|  | 				{ | ||||||
|  | 					consulta.set( MarcacaoTrabalhadorData.REALIZADA, | ||||||
|  | 								( ( Integer )consulta.get( MarcacaoTrabalhadorData.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 == 0 ) | ||||||
|  | 		{ | ||||||
|  | 			switch( index ) | ||||||
|  | 			{ | ||||||
|  | 				case INDEX_CONSULTA: | ||||||
|  | 					MarcacaoTrabalhadorData consulta = ( MarcacaoTrabalhadorData ) marcacaoConsultaPanel.save(); | ||||||
|  | 					try | ||||||
|  | 					{ | ||||||
|  | 						consulta.delete(); | ||||||
|  | 					} | ||||||
|  | 					catch( Exception ex ) | ||||||
|  | 					{ | ||||||
|  | 						DialogException.showExceptionMessage( ex, "Erro a apagar.", true ); | ||||||
|  | 						return false; | ||||||
|  | 					} | ||||||
|  | 					break; | ||||||
|  | 					 | ||||||
|  | 				case INDEX_EXAME: | ||||||
|  | 					MarcacaoTrabalhadorData exame = ( MarcacaoTrabalhadorData ) 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 ) | ||||||
|  | 		{ | ||||||
|  | 			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 = ( TrabalhadorData ) JDO.load( TrabalhadorData.class, trabalhadorID ); | ||||||
|  | //					upperPanel.getEmpresaText().setText( empresa );
 | ||||||
|  | //					upperPanel.getEstabelecimentoText().setText( estabelecimento );
 | ||||||
|  | //					upperPanel.getTrabalhadorText().setText( ( String ) trabalhador.get( TrabalhadorData.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 | ||||||
|  | 				{ | ||||||
|  | 					MarcacaoTrabalhadorData exame =  | ||||||
|  | 							( MarcacaoTrabalhadorData ) JDO.load( MarcacaoTrabalhadorData.class, exameID );			 | ||||||
|  | 					marcacaoExamePanel.fill( exame ); | ||||||
|  | 					Date dataEmailExame = ( Date ) exame.get( MarcacaoTrabalhadorData.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 | ||||||
|  | 				{ | ||||||
|  | 					MarcacaoTrabalhadorData consulta =  | ||||||
|  | 							( MarcacaoTrabalhadorData ) JDO.load( MarcacaoTrabalhadorData.class, consultaID );			 | ||||||
|  | 					marcacaoConsultaPanel.fill( consulta ); | ||||||
|  | 					Date dataEmailConsulta = ( Date ) consulta.get( MarcacaoTrabalhadorData.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() | ||||||
|  | 	{ | ||||||
|  | 		MarcacaoTrabalhadorData consulta = ( MarcacaoTrabalhadorData ) 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( MarcacaoTrabalhadorData.DATA ) ); | ||||||
|  | 			consulta.set( Marcacao.DATA_EMAIL, today ); | ||||||
|  | 		} | ||||||
|  | 		catch( Exception ex ) | ||||||
|  | 		{ | ||||||
|  | 			DialogException.showExceptionMessage( ex, "Erro a enviar mail", true ); | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	protected void enviarEmailExame() | ||||||
|  | 	{ | ||||||
|  | 		MarcacaoTrabalhadorData exame = ( MarcacaoTrabalhadorData ) 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( MarcacaoTrabalhadorData.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( TrabalhadorData.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 ); | ||||||
|  | 		 | ||||||
|  | 		EstabelecimentoData estabelecimento =  | ||||||
|  | 				( EstabelecimentoData ) JDO.load( EstabelecimentoData.class, estabelecimentoID ); | ||||||
|  | 		ContactoData contacto = ( ContactoData )estabelecimento.get( EstabelecimentoData.CONTACTO ); | ||||||
|  | 		String mail = ""; | ||||||
|  | 		if( contacto != null ) | ||||||
|  | 		{ | ||||||
|  | 			mail = ( String )contacto.get( ContactoData.EMAIL ); | ||||||
|  | 		} | ||||||
|  | 		 | ||||||
|  | 		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( SIPRPTracker tracker ) | ||||||
|  | 	{ | ||||||
|  | 		this.tracker = tracker; | ||||||
|  | 	} | ||||||
|  | } | ||||||
| @ -0,0 +1,38 @@ | |||||||
|  | /* | ||||||
|  |  * 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 java.awt.*; | ||||||
|  | import javax.swing.*; | ||||||
|  | /** | ||||||
|  |  * | ||||||
|  |  * @author fpalma | ||||||
|  |  */ | ||||||
|  | public class Test | ||||||
|  | { | ||||||
|  | 	 | ||||||
|  | 	public static void main( String args[] ) | ||||||
|  | 		throws Exception | ||||||
|  | 	{ | ||||||
|  | 		JFrame 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() | ||||||
|  | 	{ | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | } | ||||||
| @ -0,0 +1,159 @@ | |||||||
|  | ALTER TABLE empresas ADD a_consultas char(1); | ||||||
|  | ALTER TABLE empresas ADD a_exames char(1); | ||||||
|  | ALTER TABLE empresas ADD b_consultas char(1); | ||||||
|  | ALTER TABLE empresas ADD b_exames char(1); | ||||||
|  | ALTER TABLE empresas ADD data_cancelamento DATE; | ||||||
|  | 
 | ||||||
|  | ALTER TABLE marcacoes_trabalhador ADD motivo INT; | ||||||
|  | ALTER TABLE marcacoes_trabalhador ADD estado INT; | ||||||
|  | ALTER TABLE marcacoes_trabalhador ADD observacoes VARCHAR( 2048 ); | ||||||
|  | UPDATE marcacoes_trabalhador SET estado = 2 WHERE realizada = 'y'; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | -- PROTOCOLOS | ||||||
|  | 
 | ||||||
|  | CREATE TABLE prt_grupos_protocolo | ||||||
|  | ( | ||||||
|  |   id int4 NOT NULL, | ||||||
|  |   descricao varchar(255) NOT NULL, | ||||||
|  |   descricao_plain varchar(255) NOT NULL, | ||||||
|  |   CONSTRAINT grupos_protocolo_pkey PRIMARY KEY (id) | ||||||
|  | )  | ||||||
|  | WITHOUT OIDS; | ||||||
|  | ALTER TABLE prt_grupos_protocolo OWNER TO postgres; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | CREATE TABLE prt_tipos_elementos_protocolo | ||||||
|  | ( | ||||||
|  |   id int4 NOT NULL, | ||||||
|  |   descricao_plain varchar(255) NOT NULL, | ||||||
|  |   descricao varchar(255) NOT NULL, | ||||||
|  |   grupo_protocolo_id int4 NOT NULL, | ||||||
|  |   CONSTRAINT prt_tipos_elementos_protocolo_pkey PRIMARY KEY (id), | ||||||
|  |   CONSTRAINT prt_tipos_elementos_protocolo_grupo_protocolo_id_fkey FOREIGN KEY (grupo_protocolo_id) REFERENCES prt_grupos_protocolo (id) ON UPDATE RESTRICT ON DELETE RESTRICT | ||||||
|  | )  | ||||||
|  | WITHOUT OIDS; | ||||||
|  | ALTER TABLE prt_tipos_elementos_protocolo OWNER TO postgres; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | CREATE TABLE prt_elementos_protocolo | ||||||
|  | ( | ||||||
|  |   id serial NOT NULL, | ||||||
|  |   tipo_elemento_protocolo_id int4 NOT NULL, | ||||||
|  |   empresa_id int4 NOT NULL, | ||||||
|  |   numero_perfil int4 NOT NULL, | ||||||
|  |   CONSTRAINT prt_elementos_protocolo_pkey PRIMARY KEY (id), | ||||||
|  |   CONSTRAINT prt_elementos_protocolo_empresa_id_fkey FOREIGN KEY (empresa_id) REFERENCES empresas (id) ON UPDATE RESTRICT ON DELETE RESTRICT, | ||||||
|  |   CONSTRAINT prt_elementos_protocolo_tipo_elemento_protocolo_id_fkey FOREIGN KEY (tipo_elemento_protocolo_id) REFERENCES prt_tipos_elementos_protocolo (id) ON UPDATE RESTRICT ON DELETE RESTRICT | ||||||
|  | )  | ||||||
|  | WITH OIDS; | ||||||
|  | ALTER TABLE prt_elementos_protocolo OWNER TO postgres; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | CREATE TABLE marcacoes_grupos_realizados | ||||||
|  | ( | ||||||
|  |   id serial NOT NULL, | ||||||
|  |   marcacao_trabalhador_id int4 NOT NULL, | ||||||
|  |   grupo_protocolo_id int4 NOT NULL, | ||||||
|  |   CONSTRAINT marcacoes_grupos_realizados_pkey PRIMARY KEY (id), | ||||||
|  |   CONSTRAINT marcacoes_grupos_realizados_grupo_protocolo_id_fkey FOREIGN KEY (grupo_protocolo_id) REFERENCES prt_grupos_protocolo (id) ON UPDATE RESTRICT ON DELETE RESTRICT, | ||||||
|  |   CONSTRAINT marcacoes_grupos_realizados_marcacao_trabalhador_id_fkey FOREIGN KEY (marcacao_trabalhador_id) REFERENCES marcacoes_trabalhador (id) ON UPDATE RESTRICT ON DELETE RESTRICT | ||||||
|  | )  | ||||||
|  | WITH OIDS; | ||||||
|  | ALTER TABLE marcacoes_grupos_realizados OWNER TO postgres; | ||||||
|  | 
 | ||||||
|  | INSERT INTO prt_grupos_protocolo( id, descricao, descricao_plain ) | ||||||
|  | 	VALUES( 1, 'Sangue', 'sangue' ); | ||||||
|  | INSERT INTO prt_grupos_protocolo( id, descricao, descricao_plain ) | ||||||
|  | 	VALUES( 2, 'Urina', 'urina' ); | ||||||
|  | INSERT INTO prt_grupos_protocolo( id, descricao, descricao_plain ) | ||||||
|  | 	VALUES( 3, 'RX T\\u00f3rax', 'rx torax' ); | ||||||
|  | INSERT INTO prt_grupos_protocolo( id, descricao, descricao_plain ) | ||||||
|  | 	VALUES( 4, 'Audiograma', 'audiograma' ); | ||||||
|  | INSERT INTO prt_grupos_protocolo( id, descricao, descricao_plain ) | ||||||
|  | 	VALUES( 5, 'Rastreio Visual', 'rastreio visual' ); | ||||||
|  | INSERT INTO prt_grupos_protocolo( id, descricao, descricao_plain ) | ||||||
|  | 	VALUES( 6, 'ECG', 'ecg' ); | ||||||
|  | INSERT INTO prt_grupos_protocolo( id, descricao, descricao_plain ) | ||||||
|  | 	VALUES( 7, 'Espirometria', 'espirometria' ); | ||||||
|  | INSERT INTO prt_grupos_protocolo( id, descricao, descricao_plain ) | ||||||
|  | 	VALUES( 8, 'Exsudado Nasofar\\u00edngeo', 'exsudado nasofaringeo' ); | ||||||
|  | INSERT INTO prt_grupos_protocolo( id, descricao, descricao_plain ) | ||||||
|  | 	VALUES( 9, 'Exame Bacteriol\\u00f3gico (Fezes)', 'exame bacteriologico (fezes)' ); | ||||||
|  | INSERT INTO prt_grupos_protocolo( id, descricao, descricao_plain ) | ||||||
|  | 	VALUES( 10, 'Coprocultura', 'coprocultura' ); | ||||||
|  | INSERT INTO prt_grupos_protocolo( id, descricao, descricao_plain ) | ||||||
|  | 	VALUES( 11, 'Outros ECDs', 'outros ecds' ); | ||||||
|  | INSERT INTO prt_grupos_protocolo( id, descricao, descricao_plain ) | ||||||
|  | 	VALUES( 12, 'Outras An\\u00e1lises', 'outras analises' ); | ||||||
|  | 	 | ||||||
|  | INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id ) | ||||||
|  | 	values( 1, 'Hemograma', 'hemograma', 1 ); | ||||||
|  | INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id ) | ||||||
|  | 	values( 2, 'Plaquetas', 'plaquetas', 1 ); | ||||||
|  | INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id ) | ||||||
|  | 	values( 3, 'VS', 'vs', 1 ); | ||||||
|  | INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id ) | ||||||
|  | 	values( 4, 'Glicemia', 'glicemia', 1 ); | ||||||
|  | INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id ) | ||||||
|  | 	values( 5, 'Creatinina', 'creatinina', 1 ); | ||||||
|  | INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id ) | ||||||
|  | 	values( 6, 'Colesterol Total', 'colesterol total', 1 ); | ||||||
|  | INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id ) | ||||||
|  | 	values( 7, 'colesterol hdl', 'Colesterol hdl', 1 ); | ||||||
|  | INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id ) | ||||||
|  | 	values( 8, 'Colesterol LDL', 'colesterol ldl', 1 ); | ||||||
|  | INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id ) | ||||||
|  | 	values( 9, 'Trigliceridos', 'trigliceridos', 1 ); | ||||||
|  | INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id ) | ||||||
|  | 	values( 10, 'Transaminases', 'transaminases', 1 ); | ||||||
|  | INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id ) | ||||||
|  | 	values( 11, 'Gama GT', 'gama gt', 1 ); | ||||||
|  | INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id ) | ||||||
|  | 	values( 12, 'Ureia', 'ureia', 1 ); | ||||||
|  | INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id ) | ||||||
|  | 	values( 13, '\\u00c1cido \\u00darico', 'acido urico', 1 ); | ||||||
|  | INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id ) | ||||||
|  | 	values( 14, 'MBE (Chumbo)', 'mbe (chumbo)', 1 ); | ||||||
|  | INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id ) | ||||||
|  | 	values( 15, 'MBE (Outros)', 'mbe (outros)', 1 ); | ||||||
|  | INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id ) | ||||||
|  | 	values( 16, 'Serologias Hepatite', 'serologias hepatite', 1 ); | ||||||
|  | 
 | ||||||
|  | INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id ) | ||||||
|  | 	values( 17, 'Urina II', 'urina ii', 2 ); | ||||||
|  | 
 | ||||||
|  | INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id ) | ||||||
|  | 	values( 18, 'RX T\\u00f3rax', 'rx torax', 3 ); | ||||||
|  | 
 | ||||||
|  | INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id ) | ||||||
|  | 	values( 19, 'Audiometria', 'audiometria', 4 ); | ||||||
|  | 
 | ||||||
|  | INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id ) | ||||||
|  | 	values( 20, 'Rastreio Visual', 'rastreio visual', 5 ); | ||||||
|  | INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id ) | ||||||
|  | 	values( 21, 'ECG', 'ecg', 6 ); | ||||||
|  | INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id ) | ||||||
|  | 	values( 22, 'Espirometria', 'espirometria', 7 ); | ||||||
|  | INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id ) | ||||||
|  | 	values( 23, 'Exsudado Nasofar\\u00edngeo', 'exsudado nasofaringeo', 8 ); | ||||||
|  | INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id ) | ||||||
|  | 	values( 24, 'Exame Bacteriol\\u00f3gico (Fezes)', 'exame bacteriologico (fezes)', 9 ); | ||||||
|  | INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id ) | ||||||
|  | 	values( 25, 'Coprocultura', 'coprocultura', 10 ); | ||||||
|  | INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id ) | ||||||
|  | 	values( 26, 'Outros ECDs', 'outros ecds', 11 ); | ||||||
|  | INSERT INTO prt_tipos_elementos_protocolo( id, descricao, descricao_plain, grupo_protocolo_id ) | ||||||
|  | 	values( 27, 'Outras An\\u00e1lises', 'outras analises', 12 ); | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | ALTER TABLE prt_grupos_protocolo ADD grupo_real char(1); | ||||||
|  | UPDATE prt_grupos_protocolo SET grupo_real='y' WHERE id <= 4; | ||||||
|  | UPDATE prt_grupos_protocolo SET grupo_real='n' WHERE id > 4; | ||||||
|  | 
 | ||||||
|  | ALTER TABLE prt_grupos_protocolo ADD ordem int4; | ||||||
|  | UPDATE prt_grupos_protocolo SET ordem=id; | ||||||
|  | 
 | ||||||
|  | ALTER TABLE prt_tipos_elementos_protocolo ADD ordem int4; | ||||||
|  | UPDATE prt_tipos_elementos_protocolo SET ordem=id; | ||||||
					Loading…
					
					
				
		Reference in new issue