<?php include('accesscheck2.php'); 
require_once('Connections/courier.php');
require_once('functions/functions.php');
mysql_select_db($database_courier, $courier);

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;
}
}


// if(!isset($id)){
// list($id, $doc_id) = explode("@@@", $_POST['id']);
// }

if($action != 'records_insert_patient'){
$process_claim_no = mysql_real_escape_string($_POST['id']);
$patient_id_info = mysql_fetch_assoc(mysql_query("SELECT patient_id FROM process_claim_no WHERE process_claim_no='$process_claim_no'"));
$id = $patient_id_info['patient_id'];
if(empty($id)){
    $id = $process_claim_no;
}
}

$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'];
$patient_no=$row_rsodest_patient['card_number'];
$PROVIDERID=$_SESSION['provider_id'];
$type_of_client=$row_rsodest_patient['type_of_client'];
$_SESSION['client_type']=$type_of_client;

$query_rsodest_officer = "SELECT * FROM users WHERE (security='MEDICAL OFFICER' or security='OPTICIAN') AND branch_id='".$_SESSION['branch_id']."' order by title, surname, firstnames";	     
$rsodest_officer = mysql_query($query_rsodest_officer, $courier) or die(mysql_error());
$row_rsodest_officer=mysql_fetch_assoc($rsodest_officer);
$totalRows_rsodest_officer = mysql_num_rows($rsodest_officer);

// $query_rsodest_claim = "select *, DATE_FORMAT(datetimeadded, '%e %b %Y') as dateprocessing from process_claim_no where patient_no='$patient_no' and provider_id='$PROVIDERID' AND process_claim_no='$process_claim_no' order by id desc limit 1";
// $rsodest_claim = mysql_query($query_rsodest_claim, $courier) or die(mysql_error());
// $row_rsodest_claim = mysql_fetch_assoc($rsodest_claim);
// $totalRows_rsodest_claim = mysql_num_rows($rsodest_claim);
// $process_claim_no = $row_rsodest_claim['process_claim_no'];
	
	// if($totalRows_rsodest_claim>0){$showvisit='yes';}
?>

<div class="page-bar">
                        <ul class="page-breadcrumb">
                            <li>
                                <i class="icon-home"></i>
                                <a href="index.html">Home</a>
                                <i class="fa fa-angle-right"></i>
                            </li>
                            <li>
                                <span>Patient Profile</span>
                            </li>
                        </ul>
                        <div class="page-toolbar">
                             <div class="btn-group pull-right">
                                <button type="button" class="btn btn-fit-height grey-salt dropdown-toggle" data-toggle="dropdown" data-hover="dropdown" data-delay="1000" data-close-others="true"> Actions
                                    <i class="fa fa-angle-down"></i>
                                </button>
                                <ul class="dropdown-menu pull-right" role="menu">
                                    <li onclick="getstep('view_patient_visits','<?php echo $id;?>');">
                                        <a href="#">
                                            <i class="icon-refresh"></i> Refresh</a>
                                    </li>
                                    <li onclick="getstep('admin_add_new_visit');">
                                        <a href="#">
                                            <i class="icon-arrow-left"></i> Go Back </a>
                                    </li>
                                </ul>
                            </div>
                        </div>
</div>
<div class="profile-userpic" id="second_profile_pic" style="position: absolute;z-index: 2000;left: 40px;top: 0px;cursor: pointer;display: none;" onclick="movePatientProfile();">
                                          <?php $picpath=$row_rsodest_patient['picpath']; 
										  
										  if(!$picpath){ 
											
											
											if($row_rsodest_patient['insurance_no1']){
											$inspicpath=getpicpath($row_rsodest_patient['insurance_company1']);
											
											if($inspicpath){
											
											$member_id=preg_replace("/[^0-9]/","",$row_rsodest_patient['insurance_no1']);
											
											$picpath=$inspicpath."/".ltrim($member_id,0).".jpg";
											}else{
											$picpath="images/profile.gif";		
											}
											}else{
											$picpath="images/profile.gif";	
											}
										  }
										  
										  ?>
                                        
    <img src="<?php echo $picpath;?>" class="img-responsive" style="width:100px;" alt=""> 
                                    </div>

<!--<h1 class="page-title"> Patient Profile <small></small></h1>-->
                    <!-- END PAGE HEADER-->
                    <div class="row">
                        <div class="col-md-12">
                            <!-- BEGIN PROFILE SIDEBAR -->
                            <div class="profile-sidebar" id="patient_profile_sidebar">
                                <!-- PORTLET MAIN -->
                                <div class="portlet light profile-sidebar-portlet ">
                                    <!-- SIDEBAR USERPIC -->
                                    <div class="profile-userpic">
                                          <?php $picpath=$row_rsodest_patient['picpath']; 
										  
										  if(!$picpath){ 
											
											
											if($row_rsodest_patient['insurance_no1']){
											$inspicpath=getpicpath($row_rsodest_patient['insurance_company1']);
											
											if($inspicpath){
											
											$member_id=preg_replace("/[^0-9]/","",$row_rsodest_patient['insurance_no1']);
											
											$picpath=$inspicpath."/".ltrim($member_id,0).".jpg";
											}else{
											$picpath="images/profile.gif";		
											}
											}else{
											$picpath="images/profile.gif";	
											}
										  }
										  
										  ?>
                                        
                                        <img src="<?php echo $picpath;?>" class="img-responsive" alt=""> 
                                    </div>
                                    <div class="profile-usertitle">
                                        <div class="profile-usertitle-name"> <?php echo $row_rsodest_patient['surname']." ".$row_rsodest_patient['othernames'];?> </div>
                                        <div class="profile-usertitle-job"> <?php echo $row_rsodest_patient['card_number'];?> </div>
                                    </div>
                                    <div class="profile-userbuttons">
                                        <button type="button" class="btn btn-circle red btn-sm" onclick="$('#patient_profile_sidebar').hide();$('#second_profile_pic').show();">HIDE</button>
                                    </div>
                                    <div class="profile-usermenu">
                                        <ul class="nav">
                                            <li class="patient-sub-menu active" id="patient_visit" onclick="getstep('view_patient_visits','<?php echo $process_claim_no; ?>',this.id);">
                                                <a> <i class="icon-home"></i> Patient Visits </a>
                                            </li>
                                            <li class="patient-sub-menu " id="patient_info" onclick="getProcess('view_patient_information', '#patient_page_wrapper', '<?php echo $id; ?>',this.id);">
                                                <a> <i class="icon-info"></i> Patient Information </a>
                                            </li>
                                            <li class="patient-sub-menu " id="patient_edit" onclick="getProcess('edit_patient_information', '#patient_page_wrapper', '<?php echo $id; ?>',this.id);">
                                                <a> <i class="icon-pencil"></i> Edit Patient Info </a>
                                            </li>
                                            <?php //if(!empty($process_claim_no)){ ?>
                                            <li class="patient-sub-menu " id="patient_administraitve_charges" onclick="getProcess('add_administrative_charges', '#patient_page_wrapper', '<?php echo $id.'@@@'.$process_claim_no; ?>',this.id);">
                                                <a> <i class="fa fa-dollar"></i> Client Bills </a>
                                            </li>
                                            <?php //} ?>
                                             <li class="patient-sub-menu " id="patient_payments" onclick="getProcess('patient_payment_info', '#patient_page_wrapper', '<?php echo $patient_no; ?>',this.id);">
                                                <a> <i class="fa fa-dollar"></i> Client Payments </a>
                                            </li>
                                             <li class="patient-sub-menu " id="patient_send_sms" onclick="getProcess('send_sms_patient_information', '#patient_page_wrapper', '<?php echo $id; ?>',this.id);">
                                                <a> <i class="icon-envelope-open"></i> Send SMS </a>
                                            </li>
                                             <li class="patient-sub-menu " id="patient_follow_up" onclick="getProcess('follow_up_patient_information', '#patient_page_wrapper', '<?php echo $id.'@@@'.$process_claim_no; ?>',this.id);">
                                                <a> <i class="fa fa-wechat"></i> Follow Ups </a>
                                            </li>
                                             <li class="patient-sub-menu " id="patient_pick_up" onclick="getProcess('pick_up_patient_information', '#patient_page_wrapper', '<?php echo $process_claim_no; ?>',this.id);">
                                                <a> <i class="fa fa-shopping-bag"></i> Pick Ups / <b style="color:#e7505a">CLOSE VISIT</b> </a>
                                            </li>
                                        </ul>
                                    </div>
                                    <!-- END MENU -->
                                </div>
                            </div>
                            <div class="profile-content">
                                <div class="row">
                                    <div class="col-md-12">
                                        <div class="portlet light " id="patient_page_wrapper" style="min-height:800px;">
                                            <div class="portlet-title tabbable-line">
                                                <div class="caption caption-md">
                                                    <i class="icon-globe theme-font hide"></i>
                                                    <span class="caption-subject font-blue-madison bold uppercase">CLIENT VISIT INFORMATION</span>
                                                </div>
                                                <ul class="nav nav-tabs">
                                                    <li class="active">
                                                        <a href="#tab_1_1" data-toggle="tab"> List of Patient Visits </a>
                                                    </li>
                                                    <li>
                                                        <a href="#tab_1_2" data-toggle="tab">  New / Current Patient Visit </a>
                                                    </li>
                                                </ul>
                                            </div>
                                            <div class="portlet-body form">
                                                <div class="tab-content">
                                                    <div class="tab-pane active" id="tab_1_1">
                                                      <?php
//                                                      $patient_no = $row_rsodest_patient['card_number'];
                                                        $query_rsodest_claims_invoice2 = mysql_fetch_assoc(mysql_query("select *, DATE_FORMAT(datetimeadded, '%e %b %Y') as datenew from process_claim_no where patient_no='$patient_no' order by id desc limit 1", $courier));
                                                        $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";
                                                        $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); ?>
                                                       <table class="table table-striped table-bordered table-hover dataTable no-footer">
										  <thead>
										    <tr>
										      <th class="count">&nbsp;</th>
										      <th>Date of Visit</th>
										      <th>Visit No</th>
										      <th>Attending Officer</th>
										      <th>Area</th>
										      <th>Status</th>
                                              <th style="text-align: center;">Client Signature</th>
									        </tr>
									      </thead>
										  <tbody>  <?php if ($totalRows_claims_invoice> 0) { ?>
										    <?php
                                                    do {
                                                        $start_row=$start_row+1;
                                                        ?>
										    <tr>
										      <td height="23" valign="top" class="count"><span><?php echo $start_row; ?></span></td>
										      <td valign="top" style="cursor: pointer;" onclick="getclaimdetails('view_patient_visit_list','<?php echo $row_rsodest_claims_invoice['process_claim_no']; ?>','claimsno');"><?php if($checkstatus==''){$checkstatus=$row_rsodest_claims_invoice['patient_status'];}echo $row_rsodest_claims_invoice['datenew']; ?></td>
										      <td valign="top" onclick="getclaimdetails('view_patient_visit_list','<?php echo $row_rsodest_claims_invoice['process_claim_no']; ?>','claimsno');" style="cursor: pointer;"><?php echo $row_rsodest_claims_invoice['process_claim_no']; ?></td>
										      <td valign="top" onclick="getclaimdetails('view_patient_visit_list','<?php echo $row_rsodest_claims_invoice['process_claim_no']; ?>','claimsno');" style="cursor: pointer;"><?php echo $row_rsodest_claims_invoice['attending_officer']; ?></td>
										      <td valign="top" onclick="getclaimdetails('view_patient_visit_list','<?php echo $row_rsodest_claims_invoice['process_claim_no']; ?>','claimsno');" style="cursor: pointer;"><?php echo $row_rsodest_claims_invoice['area_specialisation'];?></td>
										      <td valign="top" style="cursor: pointer;" onclick="getclaimdetails('view_patient_visit_list','<?php echo $row_rsodest_claims_invoice['process_claim_no']; ?>','claimsno');">
                                              
                                              <?php if($row_rsodest_claims_invoice['patient_status']=='In Use'){$statuscolor='green';}
				  if($row_rsodest_claims_invoice['patient_status']=='Done'){$statuscolor='red';}
					  
					  echo "<span style='color:$statuscolor; font-weight:bold;'>".$row_rsodest_claims_invoice['patient_status']."</span>";?>
                                              
                                              </td>
                                              <td style="text-align: center" id="patient_signature_wrapper_<?php echo $row_rsodest_claims_invoice['process_claim_no']; ?>">
                                                          <?php $patient_signature = mysql_query("SELECT * FROM patient_signature_files WHERE process_claim_no = '".$row_rsodest_claims_invoice['process_claim_no']."' LIMIT 1", $courier);
                                                          if(mysql_num_rows($patient_signature) > 0){
                                                          $i = 1; ?>
                                                          <div class="demo-gallery">
                                                              <ul id="lightgallery" class="list-unstyled" style="width: auto;">
                                                                  <?php while ($row = mysql_fetch_assoc($patient_signature)) { ?>
                                                                      <li class="col-xs-6 col-sm-4 col-md-3" data-responsive="administrative/<?php echo $row['signature_path']; ?> 375, administrative/<?php echo $row['signature_path']; ?> 480, administrative/<?php echo $row['signature_path']; ?> 800" data-src="administrative/<?php echo $row['signature_path']; ?>" data-sub-html="<h4><?php echo date('D, jS F, Y', strtotime($row['date_time'])); ?></h4><p></p>">
                                                                          <a href="">
                                                                              <img style="height:50px" class="img-responsive" src="administrative/<?php echo $row['signature_path']; ?>">
                                                                          </a>
                                                                      </li>
                                                                      <?php $i++;
                                                                  } ?>
                                                              </ul>
                                                          </div>
                                                  
                                                          <?php } else {
                                                              if($row_rsodest_claims_invoice['patient_status']=='In Use'){?>
                                                          <a class="btn green btn-outline sbold" data-toggle="modal" href="#large"> Take Signature </a>
                                                              <?php } } ?>

                                                      </td>
                                                                                            </tr>
										    
										    <?php } while ($row_rsodest_claims_invoice = mysql_fetch_assoc($rsodest_claims_invoice)); ?>
											
											<?php }else{?>
                                            <tr>
										      <td height="23" colspan="7" valign="top" class="count">Sorry, No Patient Visits Recorded Yet.</td>
									        </tr>
                                            
                                            <?php }?>
									      </tbody>
								    </table>
                                                         
                                                        </div>
                                                    <div class="tab-pane" id="tab_1_2">
                                                        <form name="form" class="form-horizontal" role="form" id="patient_generated_visit_no">
                                                       <?php $checkstatus = $query_rsodest_claims_invoice2['patient_status'];
                                                       if($checkstatus!='In Use'){?>      
                                                            <div class="form-body">
                                                            <div class="form-group">
                                                                    <label class="col-md-4 control-label">Attending Officer</label>
                                                                    <div class="col-md-8">
                                                                        <input type="hidden" name="patient_no" id="patient_no" value="<?php echo $row_rsodest_patient['card_number']?>">
                                                                        <select onchange="if(this.value=='0'){$('#media_option_wrapper').show();$('#full_service').hide();}else{$('#media_option_wrapper').hide();$('#full_service').show();$('.part_service').hide();}" class="form-control" name="attending_officer" id="attending_officer">
                                                                            <option value="" selected> Select Attending Officer</option>
                                                                            <option value="0">No Consultation needed</option>
                                                                            <?php if ($totalRows_rsodest_officer > 0) {
                                                                                do {
                                                                                    $fullname = $row_rsodest_officer['title'] . " " . $row_rsodest_officer['firstnames'] . " " . $row_rsodest_officer['surname'] . " (" . $row_rsodest_officer['area_specialisation'] . ") - " . getnoofpatients($row_rsodest_officer['id']) . " Patients"; ?>
                                                                                    <option <?php if ($doc_id == $row_rsodest_officer['id']) {
                                                                                echo 'selected=""';
                                                                            } ?> value="<?php echo $row_rsodest_officer['id']; ?>"> <?php echo $fullname; ?></option>
                                                                             <?php } while ($row_rsodest_officer = mysql_fetch_assoc($rsodest_officer)); } ?>
                                                                        </select>
                                                                    </div>
                                                                </div>
                                                                <div style="display:none;" class="form-group" id="media_option_wrapper">
                                                                    <label class="col-md-4 control-label">How you got to know about Us</label>
                                                                    <div class="col-md-8">
                                                                        <select class="form-control" name="media_option" id="media_option">
                                                                            <option value="" selected>Please Option</option>
                                                                            <option value="Facebook">Facebook</option>
                                                                            <option value="Instagram">Instagram</option>
                                                                            <option value="Whatsapp">Whatsapp</option>
                                                                            <option value="Print Media">Print Media</option>
                                                                            <option value="Screening">Screening</option>
                                                                            <option value="Radio">Radio</option>
                                                                            <option value="Television">Television</option>
                                                                            <option value="Friend">Friend</option>
                                                                            <option value="Other">Other</option>
                                                                        </select>
                                                                    </div>
                                                                </div>
                                                                <div class="form-group">
                                                                    <label class="col-md-4 control-label">Service Type</label>
                                                                    <div class="col-md-8">
                                                                        <select class="form-control" name="service_category" id="service_category">
                                                                            <option value="" selected>Please Select Service Category</option>
                                                                            <option id="full_service" value="Full Service">Full Service</option>
                                                                            <option class="part_service" value="Part Service">Part Service</option>
                                                                            <option class="part_service" value="Frame Repair">Frame Repair</option>
                                                                        </select>
                                                                    </div>
                                                                </div>
                                                                <div class="form-group">
                                                                    <label class="col-md-4 control-label">Service Description</label>
                                                                    <div class="col-md-8">
                                                                       <input type="text" name="service_description" id="service_description" class="form-control"> 
                                                                    </div>
                                                                </div>
                                                                <div class="form-group">
                                                                    <label class="col-md-4 control-label">Mode of Payment</label>
                                                                    <div class="col-md-8">
                                                                        <select class="form-control" name="mode_of_payment" id="mode_of_payment" onchange="showtext2(this.value);if(this.value=='insurance'){$('#generate_visit_no').hide()}else{$('#generate_visit_no').show();}">
        <option value="cash" <?php if($row_rsodest_patient['type_of_client']=='cash' || !$row_rsodest_patient['type_of_client']){ echo "selected";}?>>CASH</option>
        <option value="insurance" <?php if($row_rsodest_patient['type_of_client']=='insurance'){ echo "selected";}?>>INSURANCE</option>
        <option value="company" <?php if($row_rsodest_patient['type_of_client']=='company'){ echo "selected";}?>>COMPANY</option>
        <!-- <option value="staff" <?php if($row_rsodest_patient['type_of_client']=='staff'){ echo "selected";}?>>STAFF</option> -->
        </select>
                                                                    </div>
                                                                </div>
                    <div id="insurance" style="display:<?php if($row_rsodest_patient['type_of_client']=='insurance'){ echo "block";}else{echo "none";}?>">
                                                                <div class="form-group">
                                                                    <label class="col-md-4 control-label">Insurance Company</label>
                                                                    <div class="col-md-8">
                                                                        <select class="form-control" name="insurance_com1" id="insurance_com1">
                                                                             <option value="">--Select Insurance Company --</option>
                                                                                 <?php
                                                                                    $query_rsodestship_company_name = "SELECT * FROM insurance_company where status='Active' and type='insurance' order by company_name";
                                                                                    $rsodestship_company_name = mysql_query($query_rsodestship_company_name, $courier) or die(mysql_error());
                                                                                    $row_rsodestship_company_name = mysql_fetch_assoc($rsodestship_company_name);
                                                                                    $totalRows_rsodestship_company_name = mysql_num_rows($rsodestship_company_name);
                                                                                    do {  ?>
                                                                                        <option value="<?php echo $row_rsodestship_company_name['company_code']; ?>" <?php if($row_rsodest_patient['insurance_company1']==$row_rsodestship_company_name['company_code']||$row_rsodest_patient['company']==$row_rsodestship_company_name['company_code']){ echo "selected";}?>><?php echo strtoupper($row_rsodestship_company_name['company_name']);?></option>
                                                                                        <?php
                                                                                    } while ($row_rsodestship_company_name = mysql_fetch_assoc($rsodestship_company_name));
                                                                                    $rows = mysql_num_rows($rsodestship_company_name);
                                                                                    if($rows > 0) {
                                                                                        mysql_data_seek($rsodestship_company_name, 0);
                                                                                        $row_rsodestship_company_name = mysql_fetch_assoc($rsodestship_company_name);
                                                                                    }
                                                                                    ?>
                                                                        </select>
                                                                    </div>
                                                                </div>

                                                                <div class="form-group">
                                                                    <label class="col-md-4 control-label">Insurance No.</label>
                                                                    <div class="col-md-8">
                                                                        <input type="text" class="form-control" name="insurance_no1" id="insurance_no1" value="<?php echo $row_rsodest_patient['insurance_no1']; ?>">
                                                                        <input type="hidden" name="insurance_patient_id" id="insurance_patient_id" value="<?php echo $row_rsodest_patient['card_number']; ?>">
                                                                        <input name="visit_type1" type="hidden" value="Out Patient" checked="checked">
                                                                    <?php if($row_rsodest_patient['type_of_client']=='insurance'){ ?> 
                                                                        <!-- <br><br> -->
                                                                    <div style="display:none;" id="error_via_api" class="alert alert-danger"></div>
                                                                    <div style="display:none;" id="success_via_api" class="alert alert-success"></div>   
                                                                    <div class="profile-userbuttons" onclick="processAPImemberStatus('member_status','generate_visit_no');return false;">
                                                                        <button type="button" class="btn btn-circle red btn-sm pull-left"> Validate Card </button>
                                                                    </div>
                                                                    <?php } ?> 
                                                                    </div>
                                                                </div>
                    </div>
                    <div id="company" style="display:<?php if($row_rsodest_patient['type_of_client']=='company'){ echo "block";}else{echo "none";}?>">
                                                                <div class="form-group">
                                                                    <label class="col-md-4 control-label">Insurance Company</label>
                                                                    <div class="col-md-8">
                                                                        <select class="form-control" name="insurance_company_name" id="insurance_company_name">
                                                                             <option value="">--Select Company --</option>
                                                                                 <?php
                                                                                    $query_rsodestship_company_name = "SELECT * FROM insurance_company where status='Active' and type='company' order by company_name";
                                                                                    $rsodestship_company_name = mysql_query($query_rsodestship_company_name, $courier) or die(mysql_error());
                                                                                    $row_rsodestship_company_name = mysql_fetch_assoc($rsodestship_company_name);
                                                                                    $totalRows_rsodestship_company_name = mysql_num_rows($rsodestship_company_name);
                                                                                    do {  ?>
                                                                                        <option value="<?php echo $row_rsodestship_company_name['company_code']; ?>" <?php if($row_rsodest_patient['insurance_company1']==$row_rsodestship_company_name['company_code']||$row_rsodest_patient['company']==$row_rsodestship_company_name['company_code']){ echo "selected";}?>><?php echo strtoupper($row_rsodestship_company_name['company_name']);?></option>
                                                                                        <?php
                                                                                    } while ($row_rsodestship_company_name = mysql_fetch_assoc($rsodestship_company_name));
                                                                                    $rows = mysql_num_rows($rsodestship_company_name);
                                                                                    if($rows > 0) {
                                                                                        mysql_data_seek($rsodestship_company_name, 0);
                                                                                        $row_rsodestship_company_name = mysql_fetch_assoc($rsodestship_company_name);
                                                                                    }
                                                                                    ?>
                                                                        </select>
                                                                    </div>
                                                                </div>

                                                                <div class="form-group">
                                                                    <label class="col-md-4 control-label">Company Staff No.</label>
                                                                    <div class="col-md-8">
                                                                        <input type="text" class="form-control" name="company_staff_no" id="company_staff_no" value="<?php echo $row_rsodest_patient['insurance_no1']; ?>">
                                                                        <input type="hidden" name="insurance_patient_id" id="insurance_patient_id" value="<?php echo $row_rsodest_patient['card_number']; ?>">
                                                                        <input name="visit_type1" type="hidden" value="Out Patient" checked="checked">
                                                                    </div>
                                                                </div>

                    </div>

                    
                                                            
                                                            <div style="display:<?php if($row_rsodest_patient['type_of_client']=='insurance'){ echo "none";}else{echo "block";}?>" class="form-actions right" id="generate_visit_no">
                                                                <button type="reset" class="btn default">Reset</button>
                                                                <button type="submit" class="btn green" onclick="getProcess('patientvisitno', '#patient_generated_visit_no', '<?php echo $id; ?>');return false;">Request New Visit No.</button>
                                                            </div>


                                                       <?php }else{
                                                           include("process_visit_no.php");
                                                       } ?> 
                                                            <input type="hidden" id="ins_company" name="ins_company" value="<?php echo $row_rsodest['ins_company']; ?>">
                                                            <input type="hidden" id="member_no" name="member_no" value="<?php echo $row_rsodest['member_no']; ?>">
                                                            <input type="hidden" id="user_id" name="user_id" value="<?php echo $_SESSION['myMM_Userid']; ?>">
                                                            <input type="hidden" id="process_claim_no" name="process_claim_no" value="<?php echo $process_claim_no; ?>"> 
                                                        </form>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    
                   
                    
<div class="modal fade bs-modal-lg" id="large" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-lg">
    <div class="modal-content">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
            <h4 class="modal-title">Client Signature</h4>
        </div>
        <div class="modal-body"> 
            <div class="row">
                <div style="text-align: center;cursor: pointer" class="col-md-12" id="client_signature_wrapper">
                    <label style="color: #000;font-size: 30px;cursor: pointer;" onclick="getData('load_page_client_signature','<?php echo $process_claim_no; ?>','#client_signature_wrapper');"> Click To Sign Now </label>
                </div>
            </div>
        </div>
        <div class="modal-footer">
            <button type="button" class="btn dark btn-outline" data-dismiss="modal">Close</button>
        </div>
    </div>
</div>
</div>


<div class="modal fade bs-modal-lg" id="cash_refund" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-lg">
    <div class="modal-content">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
            <h3 class="modal-title">Client Refund</h3>
        </div>
        <div class="modal-body" id="cash_refund_item_wrapper">
            <form name="" id="" class="form-horizontal">
                <table class="table" style="b">
                <tr>
                    <td style="border:none;">Amount Refunded</td>
                    <td style="border:none;"><input type="text" name="refund_amount" id="refund_amount" class="form-control"></td>
                </tr>
                <tr>
                    <td>Reason For Refund</td>
                    <td><textarea rows="3" name="refund_reason" id="refund_reason" class="form-control"></textarea></td>
                </tr>
            </table>
            </form>
        </div>
        <div class="modal-footer">
            <button id="close_modal_id" type="button" class="btn red btn-outline" data-dismiss="modal">Close</button>
            <button type="button" class="btn red" onclick="processInfo('forward_for_approval_refund','<?php echo $patient_no.'@@@'.$process_claim_no;?>');">Forward for Approval</button>
        </div>
    </div>
</div>
</div>


<div class="modal fade bs-modal-lg" id="cash_top_up" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-lg">
    <div class="modal-content">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
            <h3 class="modal-title" id="cash_top_up_title"></h3>
        </div>
        <div class="modal-body" id="cash_refund_item_wrapper">
            <form name="form" id="form" class="form-horizontal">
                <table class="table" style="b">
                <tr>
                    <td style="border:none;">Item Price</td>
                    <td style="border:none;font-size:15px;font-weight:bold;">
                        <input type="text" name="item_original_price" id="item_original_price" class="form-control" placeholder="">
                    </td>
                </tr>
                <tr>
                    <td style="border:none;">Top Up Amount</td>
                    <td style="border:none;">
                       <input type="text" name="top_up_amount" id="top_up_amount" class="form-control" placeholder="Enter amount to be paid as CASH">
                       <input type="hidden" name="item_id_cash_top_up" id="item_id_cash_top_up">
                       <p style="color:red;">Note : Please specify the amount to be paid as Cash in the field above. The rest of the amount will be treated as Insurance unless the remaining balance is Zero(0).</p>
                    </td>
                </tr>
            </table>
            </form>
        </div>
        <div class="modal-footer">
        <button id="close_modal_id" type="button" class="btn red" data-dismiss="modal">Close</button>
            <button id="" type="button" class="btn red btn-outline" onclick="$('#top_up_amount').val(0);searchItemsName('administrative_edit_claim_details_administrative','#view_items_response_wrapper_2',$('#item_id_cash_top_up').val(),'no_field');">No Top Up</button>
            <button type="button" class="btn green" onclick="searchItemsName('administrative_edit_claim_details_administrative','#view_items_response_wrapper_2',$('#item_id_cash_top_up').val(),'no_field');">Yes, Cash Top Up</button>
        </div>
    </div>
</div>
</div>
                    
                   
<script type="text/javascript">
             $(document).ready(function(){
                $('#lightgallery').lightGallery({
                    cssEasing: 'cubic-bezier(0.680, -0.550, 0.265, 1.550)'
                });
            });
    </script>