<?php include('accesscheck2.php'); 
require_once('Connections/courier.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);
if(!isset($id)){
list($id,$process_claim_no,$patient_no) = explode("@@@", $_POST['id']);
}
$query_rsodest_patient = "SELECT *, DATE_FORMAT(dateofbirth, '%D %b %Y') as datenew, (DATE_FORMAT(current_date, '%Y') - DATE_FORMAT(dateofbirth, '%Y') - (DATE_FORMAT(current_date, '00-%m-%d') < DATE_FORMAT(dateofbirth, '00-%m-%d'))) AS age FROM patient_information where id='$id'";
$rsodest_patient = mysql_query($query_rsodest_patient, $courier) or die(mysql_error());
$row_rsodest_patient = mysql_fetch_assoc($rsodest_patient);

$MEMBERSHIPID=$row_rsodest_patient['id'];
$PROVIDERID=$_SESSION['provider_id'];
$type_of_client=$row_rsodest_patient['type_of_client'];
$_SESSION['client_type']=$type_of_client;
	
?>

<?php include 'patient_header_details.php'; ?>

<div class="row"> 
    <div class="col-md-12 col-sm-12" id="patient_sub_page">
                            <div class="portlet light tasks-widget bordered" style="min-height: 400px;">
                                <div class="portlet-title">
                                    <div class="caption">
                                        <i class="icon-share font-dark hide"></i>
                                        <span class="caption-subject font-dark bold uppercase"> <span class="badge badge-danger"> <i class="icon-user"></i> </span> Patient Visits</span>
                                    </div>
                                    <div class="actions">
                                        <div class="btn-group">
                                            <a class="btn green btn-circle btn-sm" href="javascript:;" data-toggle="dropdown" data-hover="dropdown" data-close-others="true"> Actions
                                                <i class="fa fa-angle-down"></i>
                                            </a>
                                            <?php include 'patient_sub_menus.php';?>
                                        </div>
                                    </div>
                                </div>
                                <div class="portlet-body">
                                    <?php
                                                $patient_no=$row_rsodest_patient['card_number'];
                                                $query_rsodest_claims_invoice = "select *, DATE_FORMAT(datetimeadded, '%e %b %Y') as datenew from process_claim_no where patient_no='$patient_no' order by id desc";
//                                                $query_rsodest_claims_invoice = mysql_query("select m.date_time, p.*, m.id from process_claim_no p,medical_history m where p.process_claim_no=m.process_claim_no AND p.patient_no = '$patient_no' AND p.process_claim_no = '$process_claim_no' ORDER BY m.id DESC", $courier);
                                                $rsodest_claims_invoice = mysql_query($query_rsodest_claims_invoice, $courier) or die(mysql_error());
                                                $row_rsodest_claims_invoice = mysql_fetch_assoc($rsodest_claims_invoice);	
                                                $totalRows_claims_invoice = mysql_num_rows($rsodest_claims_invoice);	
                                                ?>
                                    <div class="task-content">
                                            <ul class="task-list">
                                                 <?php if ($totalRows_claims_invoice> 0) {
                                                     $i=1;
                                              do {
                                             ?>
                                                <li style="cursor: pointer;" onclick="save_information('view_medical_history_details','<?php echo $patient_no.'@@@'. $row_rsodest_claims_invoice['patient_id'];?>', '<?php echo $row_rsodest_claims_invoice['process_claim_no'];?>', 'patient_sub_page');" <?php  if (fmod($i, 2) > 0) { } else { echo 'style="background-color: #f4f6f7"';
                                                        } ?>>
                                                    <div class="task-checkbox"> <?php echo $i;?>.</div>
                                                    <div class="task-title">
                                                        <span class="task-title-sp"> <?php echo $row_rsodest_claims_invoice['attending_officer']; ?> - <b>(<?php echo $row_rsodest_claims_invoice['area_specialisation'];?>)</b> </span>
                                                        <span class="label label-sm label-success"><b>VISIT NO</b> : <?php echo $row_rsodest_claims_invoice['process_claim_no'];?></span>
                                                    </div>
                                                    <div style="margin-top: -20px;" class="pull-right">
                                                           <?php if($checkstatus==''){$checkstatus=$row_rsodest_claims_invoice['status'];}echo date('D,jS F Y g:ia', strtotime($row_rsodest_claims_invoice['datetimeadded'])); ?> 
                                                        </div>
                                                </li>
                                                 <?php $i++;  } while ($row_rsodest_claims_invoice = mysql_fetch_assoc($rsodest_claims_invoice));
                                         } ?>
                                            </ul>
                                        </div>
                                        </div>
                                    </div>
                                    <div class="task-footer">
                                        <div class="btn-arrow-link pull-right">
                                            <!--<a href="#">See All Records</a>-->
                                            <!--<i class="icon-arrow-right"></i>-->
                                        </div>
                                    </div>
                               
    </div>
                            </div>
                       