public static boolean setConsulta(Consulta consulta) {
		Connection connect = connect();
		if(connect != null){
			try {
				connect.setAutoCommit(false);
				PreparedStatement statement = connect.prepareStatement("insert into consultas (paciente, detalhes, data_inicio, data_fim) values (?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS);
				statement.setInt(1, consulta.getPaciente().getId());
				statement.setString(2, consulta.getDescricao());
				statement.setTimestamp(3, DateUtil.toSql(consulta.getData_inicio()));
				statement.setTimestamp(4, DateUtil.toSql(consulta.getData_fim()));
				statement.executeUpdate();
				
				int consultaId = -1;
				
				ResultSet keys = statement.getGeneratedKeys();
				if(keys != null && keys.next()){
					consultaId = keys.getInt(1);
				} else throw new Exception("getGeneratedKeys is empty!");
				
				if(consulta.getMedicamentos() != null && consulta.getMedicamentos().size() > 0){
					for(Medicamento medicamento : consulta.getMedicamentos()){
						String query = String.format("insert into consultas_medicamentos (consulta, medicamento) values (%d, %d)",consultaId,medicamento.getId());
						statement.executeUpdate(query);
					}
				}
				
				connect.commit();
				return true;
			} catch(Exception e){
				e.printStackTrace();
			} finally {
				close(connect);
			}
		}
		return false;
	}