|  |  | @ -227,77 +227,51 @@ System.out.println("Estabelecimentos: " + estabelecimentos.length ); | 
			
		
	
		
		
			
				
					
					|  |  |  | 		return ids; |  |  |  | 		return ids; | 
			
		
	
		
		
			
				
					
					|  |  |  | 	} |  |  |  | 	} | 
			
		
	
		
		
			
				
					
					|  |  |  | 	 |  |  |  | 	 | 
			
		
	
		
		
			
				
					
					|  |  |  | //	public void setPrestadorConsultaIdForEstabelecimentoAndDate( Integer estabelecimentoId, Date data, prestadorId )
 |  |  |  | 	public void setPrestadorConsultaIdForEstabelecimentoAndDate( Integer estabelecimentoId, Date data, Integer prestadorId ) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | //		throws Exception
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | //	{
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | //		Select selectConsultas =
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | //			new Select2( 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | //					new String[]{ "trabalhadores_consultas_datas", "trabalhadores_consultas", "trabalhadores" },
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | //					new Integer[]{ Select2.JOIN_INNER, Select2.JOIN_INNER },
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | //					new Expression[]{ 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | //						new Field( "trabalhadores_consultas_datas.trabalhadores_consultas_id" ).isEqual( new Field( "trabalhadores_consultas.id" ) ),
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | //						new Field( "trabalhadores_consultas.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ) },
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | //					new String[]{ "DISTINCT trabalhadores_consultas_datas.prestador_id" },
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | //					new Field( "trabalhadores_consultas_datas.data" ).isEqual( data ).and( 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | //						new Field( "trabalhadores.estabelecimento_id" ).isEqual( estabelecimentoId ) ).and(
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | //						new Field( "trabalhadores_consultas_datas.estado" ).isEqual( new Integer( MedicinaConstants.ESTADO_POR_REALIZAR ) ) ),
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | //					null,
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | //					null,
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | //					null,
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | //					null );
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | //		
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | //		Select selectExterno =
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | //			new Select2( 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | //				new String[]{ "trabalhadores_consultas_datas", "trabalhadores_consultas", "trabalhadores" },
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | //				new Integer[]{ Select2.JOIN_INNER, Select2.JOIN_INNER },
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | //				new Expression[]{ 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | //					new Field( "trabalhadores_consultas_datas.trabalhadores_consultas_id" ).isEqual( new Field( "trabalhadores_consultas.id" ) ),
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | //					new Field( "trabalhadores_consultas.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ) },
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | //				new String[]{ "DISTINCT trabalhadores_consultas_datas.prestador_id" },
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | //				new Field( "trabalhadores_consultas_datas.data" ).isEqual( data ).and( 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | //					new Field( "trabalhadores.estabelecimento_id" ).isEqual( estabelecimentoId ) ).and(
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | //					new Field( "trabalhadores_consultas_datas.estado" ).isEqual( new Integer( MedicinaConstants.ESTADO_POR_REALIZAR ) ) ),
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | //				null,
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | //				null,
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | //				null,
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | //				null );
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | //		Virtual2DArray arrayExterno = EXECUTER.executeQuery( selectExterno );
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | //		Integer ids[] = new Integer[ arrayExterno.columnLength() ];
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | //		for( int n = 0; n < arrayExterno.columnLength(); n++ )
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | //		{
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | //			ids[ n ] = ( Integer ) arrayExterno.get( n, 0 );
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | //		}
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | //		return ids;
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | //	}
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 	 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 	public void setPrestadorIDForEstabelecimentoAndTipo( Integer estabelecimentoID, int tipo, Date data, Integer prestadorID ) |  |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 		throws Exception |  |  |  | 		throws Exception | 
			
		
	
		
		
			
				
					
					|  |  |  | 	{ |  |  |  | 	{ | 
			
		
	
		
		
			
				
					
					|  |  |  | 		Select select = |  |  |  | 		Select selectConsultas = | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 			new Select2(  |  |  |  | 			new Select2(  | 
			
		
	
		
		
			
				
					
					|  |  |  | 					new String[]{ "marcacoes_trabalhador", "trabalhadores" }, |  |  |  | 					new String[]{ "trabalhadores_consultas", "trabalhadores" }, | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 					new Integer[]{ Select2.JOIN_INNER }, |  |  |  | 					new Integer[]{ Select2.JOIN_INNER }, | 
			
		
	
		
		
			
				
					
					|  |  |  | 					new Expression[]{  |  |  |  | 					new Expression[]{  | 
			
		
	
		
		
			
				
					
					|  |  |  | 						new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ) }, |  |  |  | 						new Field( "trabalhadores_consultas.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ) }, | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 					new String[]{ "marcacoes_trabalhador.id" }, |  |  |  | 					new String[]{ "DISTINCT trabalhadores_consultas.id" }, | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 					new Field( "marcacoes_trabalhador.data" ).isEqual( data ).and(  |  |  |  | 					new Field( "trabalhadores_consultas.data" ).isEqual( data ).and(  | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 						new Field( "trabalhadores.estabelecimento_id" ).isEqual( estabelecimentoID ) ).and(  |  |  |  | 						new Field( "trabalhadores.estabelecimento_id" ).isEqual( estabelecimentoId ) ).and( | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 						new Field( "marcacoes_trabalhador.tipo" ).isEqual( tipo ) ), |  |  |  | 						new Field( "trabalhadores_consultas.estado" ).isEqual( new Integer( MedicinaConstants.ESTADO_POR_REALIZAR ) ) ), | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 					null, |  |  |  | 					null, | 
			
		
	
		
		
			
				
					
					|  |  |  | 					null, |  |  |  | 					null, | 
			
		
	
		
		
			
				
					
					|  |  |  | 					null, |  |  |  | 					null, | 
			
		
	
		
		
			
				
					
					|  |  |  | 					null ); |  |  |  | 					null ); | 
			
		
	
		
		
			
				
					
					|  |  |  | 		Virtual2DArray array = EXECUTER.executeQuery( select ); |  |  |  | 		Update updateConsultas = new Update( "trabalhadores_consultas", | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 		for( int n = 0; n < array.columnLength(); n++ ) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 		{ |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 			Integer id = ( Integer ) array.get( n, 0 ); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 			Update update = |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 					new Update( "marcacoes_trabalhador", |  |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 												new Assignment[]{ |  |  |  | 												new Assignment[]{ | 
			
		
	
		
		
			
				
					
					|  |  |  | 									new Assignment( "prestador_id", prestadorID ) }, |  |  |  | 													new Assignment( new Field( "prestador_id" ), prestadorId ) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 								new Field( "id" ).isEqual( id ) ); |  |  |  | 												}, | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 			EXECUTER.executeQuery( update ); |  |  |  | 												new Field( "id" ).in( selectConsultas ) ); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 		} |  |  |  | 		EXECUTER.executeQuery( updateConsultas ); | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		Select selectConsultasDatas = | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			new Select2(  | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				new String[]{ "trabalhadores_consultas_datas", "trabalhadores_consultas", "trabalhadores" }, | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				new Integer[]{ Select2.JOIN_INNER, Select2.JOIN_INNER }, | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				new Expression[]{  | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 					new Field( "trabalhadores_consultas_datas.trabalhadores_consultas_id" ).isEqual( new Field( "trabalhadores_consultas.id" ) ), | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 					new Field( "trabalhadores_consultas.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ) }, | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				new String[]{ "DISTINCT trabalhadores_consultas_datas.id" }, | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				new Field( "trabalhadores_consultas_datas.data" ).isEqual( data ).and(  | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 					new Field( "trabalhadores.estabelecimento_id" ).isEqual( estabelecimentoId ) ).and( | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 					new Field( "trabalhadores_consultas_datas.estado" ).isEqual( new Integer( MedicinaConstants.ESTADO_POR_REALIZAR ) ) ), | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				null, | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				null, | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				null, | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				null ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		Update updateConsultasDatas = new Update( "trabalhadores_consultas_datas", | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				new Assignment[]{ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 					new Assignment( new Field( "prestador_id" ), prestadorId ) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				}, | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				new Field( "id" ).in( selectConsultasDatas ) ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		EXECUTER.executeQuery( updateConsultasDatas ); | 
			
		
	
		
		
			
				
					
					|  |  |  | 	} |  |  |  | 	} | 
			
		
	
		
		
			
				
					
					|  |  |  | 	 |  |  |  | 	 | 
			
		
	
		
		
			
				
					
					|  |  |  | 	protected IDObject[] getGruposEcdsByEstabelecimentoAndDate( Integer estabelecimentoId, Date data ) |  |  |  | 	protected IDObject[] getGruposEcdsByEstabelecimentoAndDate( Integer estabelecimentoId, Date data ) | 
			
		
	
	
		
		
			
				
					|  |  | 
 |