forked from Coded/SIPRP
				
			
			You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							363 lines
						
					
					
						
							8.6 KiB
						
					
					
				
			
		
		
	
	
							363 lines
						
					
					
						
							8.6 KiB
						
					
					
				|  /*
 | |
|  * ProcessoController.java
 | |
|  *
 | |
|  * Created on 25 de Abril de 2007, 15:10
 | |
|  *
 | |
|  * To change this template, choose Tools | Template Manager
 | |
|  * and open the template in the editor.
 | |
|  */
 | |
| 
 | |
| package siprp.medicina.processo;
 | |
| 
 | |
| import com.evolute.utils.Singleton;
 | |
| import com.evolute.utils.data.MappableObject;
 | |
| import com.evolute.utils.jdo.JDOProvider;
 | |
| import com.evolute.utils.ui.DialogException;
 | |
| import javax.swing.event.ListSelectionEvent;
 | |
| import javax.swing.event.ListSelectionListener;
 | |
| import siprp.data.TrabalhadorData;
 | |
| import siprp.medicina.processo.detalhes.DetalhesProcessoPanel;
 | |
| import siprp.medicina.processo.estrutura.EstruturaProcessoPanel;
 | |
| 
 | |
| /**
 | |
|  *
 | |
|  * @author Frederico
 | |
|  */
 | |
| public class ProcessoController 
 | |
| 	implements ProcessoListener, ListSelectionListener
 | |
| {
 | |
| 	protected ProcessoUpperPanel processoUpperPanel;
 | |
| 	protected EstruturaProcessoPanel estruturaProcessoPanel;
 | |
| 	protected ProcessoPanel processoPanel;
 | |
| 	protected DetalhesProcessoPanel detalhesProcessoPanel;
 | |
| 	protected ProcessoDataProvider provider;
 | |
| 	
 | |
| 	protected JDOProvider JDO;
 | |
| 	
 | |
| 	protected Integer idProcesso;
 | |
| 	protected Integer idMarcacao;
 | |
| 	protected Integer idData;
 | |
| 		
 | |
| 	/** Creates a new instance of ProcessoController */
 | |
| 	public ProcessoController( ProcessoUpperPanel processoUpperPanel, EstruturaProcessoPanel estruturaProcessoPanel, 
 | |
| 								ProcessoPanel processoPanel, DetalhesProcessoPanel detalhesProcessoPanel )
 | |
| 			throws Exception
 | |
| 	{
 | |
| 		this.processoUpperPanel = processoUpperPanel;
 | |
| 		this.estruturaProcessoPanel = estruturaProcessoPanel;
 | |
| 		this.processoPanel = processoPanel;
 | |
| 		this.detalhesProcessoPanel = detalhesProcessoPanel;
 | |
| 		processoUpperPanel.addListSelectionListener( this );
 | |
| 		estruturaProcessoPanel.addProcessoListener( this );
 | |
| 		processoPanel.addProcessoListener( this );
 | |
| 		
 | |
| 		provider = ProcessoDataProvider.getProvider();
 | |
| 		JDO = ( JDOProvider ) Singleton.getInstance( Singleton.DEFAULT_JDO_PROVIDER );
 | |
| 	}
 | |
| 
 | |
| 	public void processoStateChanged(ProcessoEvent e)
 | |
| 	{
 | |
| 		int accao = e.getAccao();
 | |
| 		switch( accao )
 | |
| 		{
 | |
| 			case ProcessoEvent.ACCAO_RECARREGAR_TRABALHADOR:
 | |
| 				recarregarTrabalhador( e );
 | |
| 				break;
 | |
| 				
 | |
| 			case ProcessoEvent.ACCAO_ESCOLHER_PROCESSO:
 | |
| 				escolherProcesso( e );
 | |
| 				break;
 | |
| 				
 | |
| 			case ProcessoEvent.ACCAO_ESCOLHER_CONSULTA:
 | |
| 				escolherConsulta( e );
 | |
| 				break;
 | |
| 				
 | |
| 			case ProcessoEvent.ACCAO_ESCOLHER_ECDS:
 | |
| 				escolherECDs( e );
 | |
| 				break;
 | |
| 				
 | |
| 			case ProcessoEvent.ACCAO_ESCOLHER_FA:
 | |
| 				escolherFichaAptidao( e );
 | |
| 				break;
 | |
| 				
 | |
| 			case ProcessoEvent.ACCAO_ESCOLHER_DATA:
 | |
| 				escolherData( e );
 | |
| 				break;
 | |
| 				
 | |
| 			case ProcessoEvent.ACCAO_ESCOLHER_OBSERVACOES:
 | |
| 				escolherObservacoes( e );
 | |
| 				break;
 | |
| 				
 | |
| 			case ProcessoEvent.ACCAO_ESCOLHER_MAIL:
 | |
| 				escolherMail( e );
 | |
| 				break;
 | |
| 				
 | |
| 			case ProcessoEvent.ACCAO_ESCOLHER_MOTIVO:
 | |
| 				escolherMotivo( e );
 | |
| 				break;
 | |
| 				
 | |
| 			case ProcessoEvent.ACCAO_MARCAR_CONSULTA:
 | |
| 				marcarConsulta( e );
 | |
| 				break;
 | |
| 				
 | |
| 			case ProcessoEvent.ACCAO_MARCAR_ECDS:
 | |
| 				marcarECDs( e );
 | |
| 				break;
 | |
| 				
 | |
| 			case ProcessoEvent.ACCAO_EMITIR_FA:
 | |
| 				emitirFichaAptidao( e );
 | |
| 				break;
 | |
| 				
 | |
| 			case ProcessoEvent.ACCAO_FECHAR:
 | |
| 				fecharProcesso( e );
 | |
| 				break;
 | |
| 				
 | |
| 			case ProcessoEvent.ACCAO_MUDAR_ESTADO_MARCACAO:
 | |
| 				mudarEstadoMarcacao( e );
 | |
| 				break;
 | |
| 				
 | |
| 			case ProcessoEvent.ACCAO_ESCREVER_OBSERVACOES:
 | |
| 				escreverObservacoes( e );
 | |
| 				break;
 | |
| 				
 | |
| 			case ProcessoEvent.ACCAO_ESCREVER_MAIL:
 | |
| 				escreverMail( e );
 | |
| 				break;
 | |
| 				
 | |
| 		}
 | |
| 	}
 | |
| 	
 | |
| 	public void recarregarTrabalhador( ProcessoEvent e )
 | |
| 	{
 | |
| 		idProcesso = null;
 | |
| 		estruturaProcessoPanel.reload();
 | |
| 	}
 | |
| 	
 | |
| 	public void escolherProcesso( ProcessoEvent e )
 | |
| 	{
 | |
| 		try
 | |
| 		{
 | |
| 			idProcesso = e.getObjecto( ProcessoEvent.TIPO_PROCESSO );
 | |
| 			processoPanel.fill( idProcesso );
 | |
| 			detalhesProcessoPanel.clear();
 | |
| 		}
 | |
| 		catch( Exception ex )
 | |
| 		{
 | |
| 		}
 | |
| 	}
 | |
| 	
 | |
| 	public void escolherConsulta( ProcessoEvent e )
 | |
| 	{
 | |
| 		try
 | |
| 		{
 | |
| 			Integer idProcessoAntigo = idProcesso;
 | |
| 			idProcesso = e.getObjecto( ProcessoEvent.TIPO_PROCESSO );
 | |
| 			if( !idProcesso.equals( idProcessoAntigo ) )
 | |
| 			{
 | |
| 				processoPanel.fill( idProcesso );
 | |
| 			}
 | |
| 			
 | |
| 			idMarcacao = e.getObjecto( ProcessoEvent.TIPO_CONSULTA );
 | |
| 		}
 | |
| 		catch( Exception ex )
 | |
| 		{
 | |
| 		}
 | |
| 	}
 | |
| 	
 | |
| 	public void escolherECDs( ProcessoEvent e )
 | |
| 	{
 | |
| 		try
 | |
| 		{
 | |
| 			idProcesso = e.getObjecto( ProcessoEvent.TIPO_PROCESSO );
 | |
| 			idMarcacao = e.getObjecto( ProcessoEvent.TIPO_CONSULTA );
 | |
| 		}
 | |
| 		catch( Exception ex )
 | |
| 		{
 | |
| 		}
 | |
| 	}
 | |
| 	
 | |
| 	public void escolherFichaAptidao( ProcessoEvent e )
 | |
| 	{
 | |
| 		try
 | |
| 		{
 | |
| 			idProcesso = e.getObjecto( ProcessoEvent.TIPO_PROCESSO );
 | |
| 			Integer idFichaAptidao = e.getObjecto( ProcessoEvent.TIPO_FICHA_APTIDAO );
 | |
| 		}
 | |
| 		catch( Exception ex )
 | |
| 		{
 | |
| 		}
 | |
| 	}
 | |
| 	
 | |
| 	public void escolherData( ProcessoEvent e )
 | |
| 	{
 | |
| 		try
 | |
| 		{
 | |
| 			idProcesso = e.getObjecto( ProcessoEvent.TIPO_PROCESSO );
 | |
| 			Integer idConsulta = e.getObjecto( ProcessoEvent.TIPO_CONSULTA );
 | |
| 			Integer idECDs = e.getObjecto( ProcessoEvent.TIPO_ECDS );
 | |
| 			idMarcacao = idConsulta != null ? idConsulta : idECDs;
 | |
| 			Integer idData = e.getObjecto( ProcessoEvent.TIPO_DATA );
 | |
| 		}
 | |
| 		catch( Exception ex )
 | |
| 		{
 | |
| 		}
 | |
| 	}
 | |
| 	
 | |
| 	public void escolherObservacoes( ProcessoEvent e )
 | |
| 	{
 | |
| 		try
 | |
| 		{
 | |
| 			idProcesso = e.getObjecto( ProcessoEvent.TIPO_PROCESSO );
 | |
| 			Integer idConsulta = e.getObjecto( ProcessoEvent.TIPO_CONSULTA );
 | |
| 			Integer idECDs = e.getObjecto( ProcessoEvent.TIPO_ECDS );
 | |
| 			idMarcacao = idConsulta != null ? idConsulta : idECDs;
 | |
| 			Integer idData = e.getObjecto( ProcessoEvent.TIPO_DATA );
 | |
| 			Integer idObservacoes = e.getObjecto( ProcessoEvent.TIPO_OBSERVACOES );
 | |
| 		}
 | |
| 		catch( Exception ex )
 | |
| 		{
 | |
| 		}
 | |
| 	}
 | |
| 	
 | |
| 	public void escolherMail( ProcessoEvent e )
 | |
| 	{
 | |
| 		try
 | |
| 		{
 | |
| 			idProcesso = e.getObjecto( ProcessoEvent.TIPO_PROCESSO );
 | |
| 			Integer idConsulta = e.getObjecto( ProcessoEvent.TIPO_CONSULTA );
 | |
| 			Integer idECDs = e.getObjecto( ProcessoEvent.TIPO_ECDS );
 | |
| 			idMarcacao = idConsulta != null ? idConsulta : idECDs;
 | |
| 			Integer idData = e.getObjecto( ProcessoEvent.TIPO_DATA );
 | |
| 			Integer idMail = e.getObjecto( ProcessoEvent.TIPO_MAIL );
 | |
| 		}
 | |
| 		catch( Exception ex )
 | |
| 		{
 | |
| 		}
 | |
| 	}
 | |
| 	
 | |
| 	public void escolherMotivo( ProcessoEvent e )
 | |
| 	{
 | |
| 		try
 | |
| 		{
 | |
| 			idProcesso = e.getObjecto( ProcessoEvent.TIPO_PROCESSO );
 | |
| 			estruturaProcessoPanel.actualizarProcessoEscolhido( idProcesso );
 | |
| 		}
 | |
| 		catch( Exception ex )
 | |
| 		{
 | |
| 			DialogException.showExceptionMessage( ex, "Erro a actualizar dados", true );
 | |
| 		}
 | |
| 	}
 | |
| 	
 | |
| 	public void marcarConsulta( ProcessoEvent e )
 | |
| 	{
 | |
| 		try
 | |
| 		{
 | |
| 			idProcesso = e.getObjecto( ProcessoEvent.TIPO_PROCESSO );
 | |
| 		}
 | |
| 		catch( Exception ex )
 | |
| 		{
 | |
| 		}
 | |
| 	}
 | |
| 	
 | |
| 	public void marcarECDs( ProcessoEvent e )
 | |
| 	{
 | |
| 		try
 | |
| 		{
 | |
| 			idProcesso = e.getObjecto( ProcessoEvent.TIPO_PROCESSO );
 | |
| 		}
 | |
| 		catch( Exception ex )
 | |
| 		{
 | |
| 		}
 | |
| 	}
 | |
| 	
 | |
| 	public void emitirFichaAptidao( ProcessoEvent e )
 | |
| 	{
 | |
| 		try
 | |
| 		{
 | |
| 			idProcesso = e.getObjecto( ProcessoEvent.TIPO_PROCESSO );
 | |
| 		}
 | |
| 		catch( Exception ex )
 | |
| 		{
 | |
| 		}
 | |
| 	}
 | |
| 	
 | |
| 	public void fecharProcesso( ProcessoEvent e )
 | |
| 	{
 | |
| 		try
 | |
| 		{
 | |
| 			idProcesso = e.getObjecto( ProcessoEvent.TIPO_PROCESSO );
 | |
| 			estruturaProcessoPanel.actualizarProcessoEscolhido( idProcesso );
 | |
| 		}
 | |
| 		catch( Exception ex )
 | |
| 		{
 | |
| 		}
 | |
| 	}
 | |
| 	
 | |
| 	public void mudarEstadoMarcacao( ProcessoEvent e )
 | |
| 	{
 | |
| 		try
 | |
| 		{
 | |
| 			idProcesso = e.getObjecto( ProcessoEvent.TIPO_PROCESSO );
 | |
| 			Integer idConsulta = e.getObjecto( ProcessoEvent.TIPO_CONSULTA );
 | |
| 			Integer idECDs = e.getObjecto( ProcessoEvent.TIPO_ECDS );
 | |
| 			idMarcacao = idConsulta != null ? idConsulta : idECDs;
 | |
| 		}
 | |
| 		catch( Exception ex )
 | |
| 		{
 | |
| 		}
 | |
| 	}
 | |
| 	
 | |
| 	public void escreverObservacoes( ProcessoEvent e )
 | |
| 	{
 | |
| 		try
 | |
| 		{
 | |
| 			idProcesso = e.getObjecto( ProcessoEvent.TIPO_PROCESSO );
 | |
| 			Integer idConsulta = e.getObjecto( ProcessoEvent.TIPO_CONSULTA );
 | |
| 			Integer idECDs = e.getObjecto( ProcessoEvent.TIPO_ECDS );
 | |
| 			idMarcacao = idConsulta != null ? idConsulta : idECDs;
 | |
| 		}
 | |
| 		catch( Exception ex )
 | |
| 		{
 | |
| 		}
 | |
| 	}
 | |
| 	
 | |
| 	public void escreverMail( ProcessoEvent e )
 | |
| 	{
 | |
| 		try
 | |
| 		{
 | |
| 			idProcesso = e.getObjecto( ProcessoEvent.TIPO_PROCESSO );
 | |
| 			Integer idConsulta = e.getObjecto( ProcessoEvent.TIPO_CONSULTA );
 | |
| 			Integer idECDs = e.getObjecto( ProcessoEvent.TIPO_ECDS );
 | |
| 			idMarcacao = idConsulta != null ? idConsulta : idECDs;
 | |
| 		}
 | |
| 		catch( Exception ex )
 | |
| 		{
 | |
| 		}
 | |
| 	}
 | |
| 
 | |
| 	public void valueChanged(ListSelectionEvent e)
 | |
| 	{
 | |
| 		try
 | |
| 		{
 | |
| 			Integer ids[] = ( Integer [] ) processoUpperPanel.save();
 | |
| 			Integer trabalhadorID = ids[ 2 ];
 | |
| 			processoPanel.setTrabalhadorID( trabalhadorID );
 | |
| 			if( trabalhadorID != null )
 | |
| 			{
 | |
| 				TrabalhadorData trabalhador = ( TrabalhadorData ) JDO.load( TrabalhadorData.class, trabalhadorID );
 | |
| 				estruturaProcessoPanel.setTrabalhador( new MappableObject( trabalhadorID, trabalhador.get( TrabalhadorData.NOME ) ) );
 | |
| 			}
 | |
| 			else
 | |
| 			{
 | |
| 				estruturaProcessoPanel.clear();
 | |
| 			}
 | |
| 			processoPanel.clear();
 | |
| 			detalhesProcessoPanel.clear();
 | |
| 		}
 | |
| 		catch( Exception ex )
 | |
| 		{
 | |
| 			DialogException.showExceptionMessage( ex, "Erro a carregar trabalhador", true );
 | |
| 		}
 | |
| 	}
 | |
| }
 |