|  |  | @ -42,6 +42,21 @@ public class doGetListaTrabalhadoresPendentes | 
			
		
	
		
		
			
				
					
					|  |  |  | 	protected static int MOTIVO_OCASIONAL = 3; |  |  |  | 	protected static int MOTIVO_OCASIONAL = 3; | 
			
		
	
		
		
			
				
					
					|  |  |  | 	protected static int MOTIVO_PERIODICA_INICIAL = 5; |  |  |  | 	protected static int MOTIVO_PERIODICA_INICIAL = 5; | 
			
		
	
		
		
			
				
					
					|  |  |  | 	 |  |  |  | 	 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	protected static final Hashtable CORES_ESTADOS = new Hashtable(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	protected static final Hashtable TEXTOS_ESTADOS = new Hashtable(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	static | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	{ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		CORES_ESTADOS.put( new Integer( ESTADO_NAO_APLICAVEL ), "white" ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		CORES_ESTADOS.put( new Integer( ESTADO_PENDENTE ), "red" ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		CORES_ESTADOS.put( new Integer( ESTADO_MARCADO ), "yellow" ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		CORES_ESTADOS.put( new Integer( ESTADO_TRATADO ), "green" ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		TEXTOS_ESTADOS.put( new Integer( ESTADO_NAO_APLICAVEL ), "n.a." ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		TEXTOS_ESTADOS.put( new Integer( ESTADO_PENDENTE ), "pendente" ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		TEXTOS_ESTADOS.put( new Integer( ESTADO_MARCADO ), "pendente" ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | //		TEXTOS_ESTADOS.put( new Integer( ESTADO_TRATADO ), "green" );
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	 | 
			
		
	
		
		
			
				
					
					|  |  |  | 	protected java.sql.Date today; |  |  |  | 	protected java.sql.Date today; | 
			
		
	
		
		
			
				
					
					|  |  |  | 	protected long todayMillis; |  |  |  | 	protected long todayMillis; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | @ -298,9 +313,13 @@ public class doGetListaTrabalhadoresPendentes | 
			
		
	
		
		
			
				
					
					|  |  |  | 					 |  |  |  | 					 | 
			
		
	
		
		
			
				
					
					|  |  |  | 					for( int n = 0; n < trabalhadores.length; n++ ) |  |  |  | 					for( int n = 0; n < trabalhadores.length; n++ ) | 
			
		
	
		
		
			
				
					
					|  |  |  | 					{ |  |  |  | 					{ | 
			
		
	
		
		
			
				
					
					|  |  |  | 						Object marcacoes[][] = ( Object[][] ) marcacoesPorID.get( trabalhadores[ n ].getID() ); |  |  |  | 						Object marcacoes[][] = ( Object[][] ) ( ( Vector )marcacoesPorID.get( trabalhadores[ n ].getID() ) ).toArray( new Object[ 0 ][] ); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 						Object ocasionais[][] = ( Object[][] ) ocasionaisPorID.get( trabalhadores[ n ].getID() ); |  |  |  | 						Object ocasionais[][] = ( Object[][] ) ( ( Vector )ocasionaisPorID.get( trabalhadores[ n ].getID() ) ).toArray( new Object[ 0 ][] ); | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 						Object agrupadas[][] = agruparMarcacoes( marcacoes, ocasionais ); |  |  |  | 						Object agrupadas[][] = agruparMarcacoes( marcacoes, ocasionais ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 						acrescentarTrabalhador( empresaId, estabelecimentoId, | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 												trabalhadores[ n ], null,  | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 												agrupadas, links, desc, | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 												true, true ); | 
			
		
	
		
		
			
				
					
					|  |  |  | 					} |  |  |  | 					} | 
			
		
	
		
		
			
				
					
					|  |  |  | 										 |  |  |  | 										 | 
			
		
	
		
		
			
				
					
					|  |  |  | 					HashMap hmValues = new HashMap(); |  |  |  | 					HashMap hmValues = new HashMap(); | 
			
		
	
	
		
		
			
				
					|  |  | @ -475,12 +494,13 @@ public class doGetListaTrabalhadoresPendentes | 
			
		
	
		
		
			
				
					
					|  |  |  | 		return agrupadas; |  |  |  | 		return agrupadas; | 
			
		
	
		
		
			
				
					
					|  |  |  | 	} |  |  |  | 	} | 
			
		
	
		
		
			
				
					
					|  |  |  | 	 |  |  |  | 	 | 
			
		
	
		
		
			
				
					
					|  |  |  | 	protected void acrescentarTrabalhador( IDObject trabalhador, java.util.Date dataFicha,  |  |  |  | 	protected void acrescentarTrabalhador( String empresaID, String estabelecimentoID, | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 											IDObject trabalhador, java.util.Date dataFicha,  | 
			
		
	
		
		
			
				
					
					|  |  |  | 											Object marcacoes[][], Vector links, Vector dados, |  |  |  | 											Object marcacoes[][], Vector links, Vector dados, | 
			
		
	
		
		
			
				
					
					|  |  |  | 											boolean perfilConsultas, boolean perfilExames ) |  |  |  | 											boolean perfilConsultas, boolean perfilExames ) | 
			
		
	
		
		
			
				
					
					|  |  |  | 	{ |  |  |  | 	{ | 
			
		
	
		
		
			
				
					
					|  |  |  | 		int estado[] = new int[ 2 ]; |  |  |  | 		int estado[] = new int[ 2 ]; | 
			
		
	
		
		
			
				
					
					|  |  |  | 		 |  |  |  | 		int index = 0; | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 		if( marcacoes.length == 0 ) |  |  |  | 		if( marcacoes.length == 0 ) | 
			
		
	
		
		
			
				
					
					|  |  |  | 		{ |  |  |  | 		{ | 
			
		
	
		
		
			
				
					
					|  |  |  | 			estado[ 0 ] = perfilConsultas ? ESTADO_PENDENTE : ESTADO_NAO_APLICAVEL; |  |  |  | 			estado[ 0 ] = perfilConsultas ? ESTADO_PENDENTE : ESTADO_NAO_APLICAVEL; | 
			
		
	
	
		
		
			
				
					|  |  | @ -490,7 +510,7 @@ public class doGetListaTrabalhadoresPendentes | 
			
		
	
		
		
			
				
					
					|  |  |  | 		{ |  |  |  | 		{ | 
			
		
	
		
		
			
				
					
					|  |  |  | 			java.util.Date dataConsulta; |  |  |  | 			java.util.Date dataConsulta; | 
			
		
	
		
		
			
				
					
					|  |  |  | 			java.util.Date dataExame; |  |  |  | 			java.util.Date dataExame; | 
			
		
	
		
		
			
				
					
					|  |  |  | 			int index = -1; |  |  |  | 			index = -1; | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 			for( ; index + 1 < marcacoes.length; index++ ) |  |  |  | 			for( ; index + 1 < marcacoes.length; index++ ) | 
			
		
	
		
		
			
				
					
					|  |  |  | 			{ |  |  |  | 			{ | 
			
		
	
		
		
			
				
					
					|  |  |  | 				int n = index + 1; |  |  |  | 				int n = index + 1; | 
			
		
	
	
		
		
			
				
					|  |  | @ -518,18 +538,99 @@ public class doGetListaTrabalhadoresPendentes | 
			
		
	
		
		
			
				
					
					|  |  |  | 				index = 0; |  |  |  | 				index = 0; | 
			
		
	
		
		
			
				
					
					|  |  |  | 			} |  |  |  | 			} | 
			
		
	
		
		
			
				
					
					|  |  |  | 			boolean found = false; |  |  |  | 			boolean found = false; | 
			
		
	
		
		
			
				
					
					|  |  |  | 			for( ; !found; index++ ) |  |  |  | 			for( ; !found && index < marcacoes.length; index++ ) | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 			{ |  |  |  | 			{ | 
			
		
	
		
		
			
				
					
					|  |  |  | //				java.util.Date dataConsulta = ( java.util.Date ) marcacoes[ n ][ 0 ];
 |  |  |  | 				dataConsulta = ( java.util.Date ) marcacoes[ index ][ 0 ]; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //				java.util.Date dataExame = ( java.util.Date ) marcacoes[ n ][ 3 ];
 |  |  |  | 				dataExame = ( java.util.Date ) marcacoes[ index ][ 3 ]; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //				if( ( dataConsulta == null || dataConsulta.before( today ) ) !=
 |  |  |  | 				boolean temConsulta = dataConsulta != null; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //					( dataExame == null || dataExame.before( today ) ) )
 |  |  |  | 				long diffConsulta = temConsulta ? dataConsulta.getTime() - today.getTime() : 0; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //				{
 |  |  |  | 				boolean temExame = dataExame != null; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //					break;
 |  |  |  | 				long diffExame = temExame ? dataExame.getTime() - today.getTime() : 0; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //				}
 |  |  |  | 				if( ( temConsulta && diffConsulta < CATORZE_DIAS ) || ( temExame && diffExame < CATORZE_DIAS ) ) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 				{ | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 					found = true; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			if( index >= marcacoes.length ) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			{ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				index = marcacoes.length - 1; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			else | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			{ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				if( marcacoes.length > 1 ) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				{ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 					dataConsulta = ( java.util.Date ) marcacoes[ index ][ 0 ]; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 					dataExame = ( java.util.Date ) marcacoes[ index ][ 3 ]; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 					Calendar calToday = Calendar.getInstance(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 					calToday.setTime( today ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 					calToday.add( Calendar.YEAR, -2 ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 					if( dataConsulta.before( calToday.getTime() ) ) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 					{ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 						index++; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 					} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			dataConsulta = ( java.util.Date ) marcacoes[ index ][ 0 ]; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			Integer estadoConsulta = ( Integer ) marcacoes[ index ][ 1 ]; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			Integer motivoConsulta = ( Integer ) marcacoes[ index ][ 2 ]; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			dataExame = ( java.util.Date ) marcacoes[ index ][ 3 ]; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			Integer estadoExame = ( Integer ) marcacoes[ index ][ 4 ]; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			if( perfilConsultas ) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			{ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				if( dataConsulta == null ) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				{ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 					estado[ 0 ] = ESTADO_PENDENTE; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				else if( estadoConsulta == null || estadoConsulta.intValue() != 2 ) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				{ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 					estado[ 0 ] = ESTADO_MARCADO; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				else | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				{ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 					estado[ 0 ] = ESTADO_TRATADO; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			else | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			{ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				estado[ 0 ] = ESTADO_NAO_APLICAVEL; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			if( perfilExames ) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			{ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				if( dataExame == null ) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				{ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 					if( motivoConsulta != null && motivoConsulta.intValue() != MOTIVO_OCASIONAL ) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 					{ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 						estado[ 1 ] = ESTADO_PENDENTE; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 					} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 					else | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 					{ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 						estado[ 1 ] = ESTADO_NAO_APLICAVEL; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 					} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				else if( estadoExame == null || estadoExame.intValue() != 2 ) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				{ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 					estado[ 1 ] = ESTADO_MARCADO; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				else | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				{ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 					estado[ 1 ] = ESTADO_TRATADO; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			else | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			{ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				estado[ 1 ] = ESTADO_NAO_APLICAVEL; | 
			
		
	
		
		
			
				
					
					|  |  |  | 			} |  |  |  | 			} | 
			
		
	
		
		
			
				
					
					|  |  |  | 		} |  |  |  | 		} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		links.add( "/"+servletName+"/?"+empresaID+"/"+estabelecimentoID+"/"+trabalhador.getID() ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		HashMap dadosTrabalhador = new HashMap(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		dadosTrabalhador.put( "Nome", trabalhador.toString() ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		dadosTrabalhador.put( "Consulta", CORES_ESTADOS.get( new Integer( estado[ 0 ] ) ) ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		Object text = TEXTOS_ESTADOS.get( new Integer( estado[ 0 ] ) ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		dadosTrabalhador.put( "Consulta_estado", text != null ? text : marcacoes[ index ][ 0 ] ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		dadosTrabalhador.put( "Exame", CORES_ESTADOS.get( new Integer( estado[ 1 ] ) ) ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		text = TEXTOS_ESTADOS.get( new Integer( estado[ 0 ] ) ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		dadosTrabalhador.put( "Exame_estado", text != null ? text : marcacoes[ index ][ 3 ] ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		dados.add( dadosTrabalhador ); | 
			
		
	
		
		
			
				
					
					|  |  |  | 	} |  |  |  | 	} | 
			
		
	
		
		
			
				
					
					|  |  |  | 	 |  |  |  | 	 | 
			
		
	
		
		
			
				
					
					|  |  |  | //	protected boolean verificarTrabalhador( Object consultas[][], Object exames[][] )
 |  |  |  | //	protected boolean verificarTrabalhador( Object consultas[][], Object exames[][] )
 | 
			
		
	
	
		
		
			
				
					|  |  | 
 |