<?php 

include('accesscheck2.php');
require_once('Connections/courier.php'); 
require_once('functions/functions.php'); 
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

mysql_select_db($database_courier, $courier);
$searchtxt=$_POST["searchtext_patient_no"];
$id = mysql_real_escape_string($_POST['id']);

if($action=='medical_list_claims_search'){
	//echo "mee";
$query_rsodest = "SELECT b.*, b.id as patient_id FROM patient_information b 
                 WHERE ( old_card_no like '%$searchtxt%' or card_number like '%$searchtxt%') ORDER BY b.id ASC LIMIT 100";	
}

$rsodest = mysql_query($query_rsodest, $courier) or die(mysql_error());
$totalRows_rsodest = mysql_num_rows($rsodest);
$row_rsodest = mysql_fetch_assoc($rsodest);
?>
<div class="row">
    <div class="col-md-12" id="patient_sub_page">
                            <!-- BEGIN Portlet PORTLET-->
                            <div class="portlet light bordered" style="min-height: 400px;">
                                <div class="portlet-title">
                                    <div class="caption font-green-sharp">
                                        <i class="icon-users font-green-sharp"></i>
                                        <span class="caption-subject bold"> Click to Upload Patient's Folder </span>
                                    </div>
                                  </div>
                                <div class="portlet-body">
                                     <?php
                                     if($totalRows_rsodest > 0){
                                     do {
                                         list($row_rsodest['picpath'], $row_rsodest['insurance_no1'], $row_rsodest['insurance_company1']) = patient_sub_info($row_rsodest['card_number'], $courier);
                                         $picpath="../".FOLDER_NAME.$row_rsodest['picpath']; 
										  if(!$picpath){ 
											if($row_rsodest['insurance_no1']){
											$inspicpath=getpicpath($row_rsodest['insurance_company1']);
											if($inspicpath){
											$member_id=preg_replace("/[^0-9]/","",$row_rsodest['insurance_no1']);
											$picpath="../".FOLDER_NAME.$inspicpath."/".ltrim($member_id,0).".jpg";
											}else{
											$picpath="../".FOLDER_NAME."images/profile.gif";		
											}
											}else{
											$picpath="../".FOLDER_NAME."images/profile.gif";	
											}
										  }?>  
                                    <?php
                                    $medical_note_id = 0;
                                    ?>
                                    <?php if($id=='pending_diagnostic'||$action == 'medical_list_claims' || $action=='medical_list_claims_search'){ ?>
                                    <div class="mt-comments" style="cursor: pointer;" onclick="Repeat_Patient_Play_2('repeat_patient_calling','<?php echo $row_rsodest['patient_id'].'@@@'.$row_rsodest['patient_no'].'@@@'.$row_rsodest['process_claim_no'];?>','You are about to Call In This Patient.','view_medical_history_details','<?php echo $row_rsodest['patient_no'].'@@@'.$row_rsodest['patient_id'];?>', '<?php echo $row_rsodest['process_claim_no'];?>', 'currentarea','<?php echo $medical_note_id;?>');">
                                    <?php }else{ ?>
                                    <div class="mt-comments" style="cursor: pointer;" onclick="save_information('view_medical_history_details','<?php echo $row_rsodest['patient_no'].'@@@'. $row_rsodest['patient_id'];?>', '<?php echo $row_rsodest['process_claim_no'];?>', 'currentarea','<?php echo $medical_note_id;?>');">
                                    <?php } ?>  
                                    <?php if($action == 'medical_list_claims' || $action == 'medical_list_claims_search'){ ?>
                                    <div class="mt-comment" style="background-color: #FAFAFA;border: 1px solid #eee;">
                                            <div class="mt-comment-img">
                                                <img style="width:40px;height: 40px;" src="<?php echo $picpath;?>"> 
                                            </div>
                                            <div class="mt-comment-body">
                                                <div class="mt-comment-info">
                                                    <span class="mt-comment-author"> <?php echo strtoupper($row_rsodest['surname']." ".$row_rsodest['othernames']); ?> - ( <?php echo $row_rsodest['card_number'];?> ) </span>
                                                    <span class="mt-comment-date"><?php echo timeAgo($row_rsodest['datetimeadded']).' ago'; ?></span>
                                                </div>
                                                <div class="mt-comment-text"> VISIT NO : N/A </div>
                                                <div class="mt-comment-details">
                                                    <span class="mt-comment-status mt-comment-status-pending">
                                                        <?php if($row_rsodest['status']=='In Use'){$statuscolor='green';}if($row_rsodest['status']=='Submitted'){$statuscolor='red';}echo "<span style='color:$statuscolor; font-weight:bold;'>".strtoupper($row_rsodest['status'])."</span>";?>
                                                    </span><ul class="mt-comment-actions" style="display: block"><li><a href="#">View</a></li></ul>
                                                </div>
                                            </div>
                                    </div>
                                        
                                    <?php } ?>   
                                    </div>
                                        <form name="form" id="form" method="POST">
                                        <input type="hidden" name="patient_id" value="<?php echo $row_rsodest['id']; ?>">
                                        <input type="hidden" name="patient_no" value="<?php echo $row_rsodest['card_number']; ?>">
                                        <input type="hidden" name="new_id" value="<?php echo $row_rsodest['card_number']; ?>">
                                        </form>
                                                    <?php }  while ($row_rsodest = mysql_fetch_assoc($rsodest));
                                     } else{ ?>
                                         <div class="mt-comments" style="cursor: pointer;">
                                        <div class="mt-comment" style="background-color: #FAFAFA;border: 1px solid #eee;">
                                                    <div class="mt-comment-img"></div>
                                                    <div class="mt-comment-body">
                                                        <div class="mt-comment-info">
                                                            <span class="mt-comment-author" style="color: red;"> NO PATIENTS FOUND </span>
                                                            <span class="mt-comment-date"></span>
                                                        </div>
                                                        <div class="mt-comment-text"></div>
                                                        <div class="mt-comment-details"></div>
                                                    </div>
                                                </div>
                                    </div>
                                     <?php  } ?>
                                    
                                        </div>
                                    </div>
                                </div>
                            </div>
                        
    
    
    