echo $coded;
                ?>
  </td>
 </tr>
<?php 
            } else {
                if ($docname != $lastdocname) {
                    show_doc_total($lastdocname, $doc_encounters);
                    $doc_encounters = 0;
                }
                ++$doc_encounters;
            }
            $lastdocname = $docname;
        }
        if (!$form_details) {
            show_doc_total($lastdocname, $doc_encounters);
        }
    }
    ?>
</tbody>
</table>
</div>  <!-- end encresults -->
<?php 
} else {
    ?>
<div class='text'>
 	<?php 
    echo xl('Please input search criteria above, and click Submit to view results.', 'e');
    ?>
</div>
<?php 
  <td>
   <?php echo $coded; ?>
  </td>
 </tr>
<?php
    } else {
      if ($docname != $lastdocname) {
        show_doc_total($lastdocname, $doc_encounters);
        $doc_encounters = 0;
      }
      ++$doc_encounters;
    }
    $lastdocname = $docname;
  }

  if (!$form_details) show_doc_total($lastdocname, $doc_encounters);
}
?>
</tbody>
</table>
</div>  <!-- end encresults -->
<?php } else { ?>
<div class='text'>
 	<?php echo xl('Please input search criteria above, and click Submit to view results.', 'e' ); ?>
</div>
<?php } ?>

<input type="hidden" name="form_orderby" value="<?php echo $form_orderby ?>" />
<input type='hidden' name='form_refresh' id='form_refresh' value=''/>

</form>