$query_parameters = drupal_get_query_parameters();
//Check if the specified query paramater key is present in the current URL
if (empty($query_parameters['query_paramater_key'])) {
$form_state['redirect'] = array('node/123',
array('query' => array('foo' => 'bar'),'fragment' => 'baz');
}