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.
		
		
		
		
		
			
		
			
				
					
					
						
							94 lines
						
					
					
						
							3.9 KiB
						
					
					
				
			
		
		
	
	
							94 lines
						
					
					
						
							3.9 KiB
						
					
					
				| /*
 | |
|  * 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();
 | |
| 		}
 | |
| 	}
 | |
| }
 |