<?php session_start();
include('../accesscheck2.php');
require_once('../Connections/courier.php'); 
require_once('../functions/functions.php'); 

    list($month,$year,$ins_company,$claim_area) = explode("@@@", $_GET['id']);

    $facility_number=$_SESSION['facility_number'];
    $provider_id=$_SESSION['provider_id'];
    $facility_name=$_SESSION['facility_name'];

    $query_rsodest_facility = "SELECT * FROM provider_api where provider_id='$facility_number'";		
    $rsodest_facility = mysql_query($query_rsodest_facility, $courier) or die(mysql_error());
    $row_rsodest_facility = mysql_fetch_assoc($rsodest_facility);
    $current_date=date('Y-m-d');
    ?>
<!DOCTYPE html>
<html lang="en">
<head>
        <meta charset="utf-8" />
        <title> Optical Management System </title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta content="width=device-width, initial-scale=1" name="viewport" />
        <meta content="" name="description" />
        <meta content="" name="author" />
        <!-- BEGIN GLOBAL MANDATORY STYLES -->
        <link href="http://fonts.googleapis.com/css?family=Open+Sans:400,300,600,700&subset=all" rel="stylesheet" type="text/css" />
        <!--<link href="../assets/global/css/font.css?family=Open+Sans:400,300,600,700&subset=all" rel="stylesheet" type="text/css" />-->
        <link href="../assets/global/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
        <link href="../assets/global/plugins/uniform/css/uniform.default.css" rel="stylesheet" type="text/css" />
        <link href="../assets/global/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
        <!-- <link href="../assets/global/plugins/bootstrap-switch/css/bootstrap-switch.min.css" rel="stylesheet" type="text/css" /> -->
        <!-- END GLOBAL MANDATORY STYLES -->
        
        <!-- BEGIN DYMANICLY LOADED CSS FILES(all plugin and page related styles must be loaded between GLOBAL and THEME css files ) -->
        <!-- END DYMANICLY LOADED CSS FILES -->
        
        <!-- BEGIN PAGE LEVEL PLUGINS -->
        <link href="../assets/global/plugins/morris/morris.css" rel="stylesheet" type="text/css" />
        <!-- END PAGE LEVEL PLUGINS -->
        <!-- BEGIN THEME GLOBAL STYLES -->
        <link href="../assets/global/css/components.min.css" rel="stylesheet" id="style_components" type="text/css" />
        <!-- END THEME GLOBAL STYLES -->
        <!-- BEGIN THEME LAYOUT STYLES -->
        <link href="../assets/admin/layouts/css/layout.min.css" rel="stylesheet" type="text/css" />
        
        <!-- END THEME LAYOUT STYLES -->
        <script>
    </script>

    <style  type="text/css" media="print">
           .print_button{
               display:none;
           }
           h6#breakmenow {page-break-after: always}
    </style>
    
    </head>


    <body class="page-sidebar-closed-hide-logo page-container-bg-solid page-boxed page-header-fixed" >

        <?php 
                $query_rsodest = "SELECT DISTINCT a.process_claim_no, a.ins_company,  DATE_FORMAT(a.date_of_consultation, '%D %M %Y') as dateconsult, DATE_FORMAT(b.dateofbirth, '%D %M %Y') as datenew, (DATE_FORMAT(current_date, '%Y') - DATE_FORMAT(b.dateofbirth, '%Y') - (DATE_FORMAT(current_date, '00-%m-%d') < DATE_FORMAT(b.dateofbirth, '00-%m-%d'))) AS age, b.* from claims_details a LEFT JOIN patient_information b on a.patient_no=b.card_number where MONTH(a.date_of_consultation)='$month' AND YEAR(a.date_of_consultation)='$year' AND a.ins_company='$ins_company' AND (a.mode_of_payment='$claim_area') ORDER BY a.date_of_consultation DESC";	
                // $query_rsodest = "SELECT a.*, a.id as claim_id, a.status as claimstatus, b.id as patient_id, DATE_FORMAT(a.date_added, '%D %M %Y') as dateconsult,  b.*, DATE_FORMAT(b.dateofbirth, '%D %M %Y') as datenew, DATE_FORMAT(b.expiry_date, '%D %M %Y') as dateexpiry, (DATE_FORMAT(current_date, '%Y') - DATE_FORMAT(b.dateofbirth, '%Y') - (DATE_FORMAT(current_date, '00-%m-%d') < DATE_FORMAT(b.dateofbirth, '00-%m-%d'))) AS age, b.status as member_status FROM process_claim_no a left join patient_information b on a.patient_no=b.card_number where a.process_claim_no='$id' order by a.id desc";	
                $rsodest = mysql_query($query_rsodest);
                // $row_rsodest = mysql_fetch_assoc($rsodest);
                while($row_rsodest = mysql_fetch_assoc($rsodest)){
                $process_claim_no = $row_rsodest['process_claim_no'];
                $picpath=$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=$inspicpath."/".ltrim($member_id,0).".jpg";
                    }else{
                    $picpath="images/profile.gif";		
                    }
                    }else{
                    $picpath="images/profile.gif";	
                    }
                }
             ?>
<div class="container">
             <div class="page-container">
                <div class="page-content">
    <div class="row">
        <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
        <button onclick="window.close();" type="button" class="btn red pull-right print_button">Close Page <i class="fa fa-close"></i> </button>
        <button onclick="window.print();" type="button" class="btn green pull-right print_button">Print Page <i class="fa fa-print"></i> </button>
<div class="col-xs-2 col-sm-2 col-md-2 col-lg-2">
<table width="100%" class="table">
                                    <thead>
                                        <tr>
                                            <th colspan="3" valign="middle" class="baseborder"> PATIENT PICTURE </th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                    <tr>
                                    <td>
                                    <div class="profile-userpic">
                                        <img src="<?php echo '../'. $picpath;?>" class="img-responsive"> 
                                    </div>
                                    </td>
                                    </tr>
                                    </tbody>
                                    </table>
</div>
<div class="col-xs-5 col-sm-5 col-md-5 col-lg-5">
    <table width="100%" border="0" cellpadding="1" cellspacing="1" class="table">
                                    <thead>
                                        <tr>
                                            <th colspan="3" valign="middle" class="baseborder"> CLIENT INFORMATION </th>
                                        </tr>
                                    </thead>
                                          <tbody>
                                         <tr class="baseborder">
                                           <td height="30" align="right" style="text-align: left;font-weight:bold;">Client ID</td>
                                           <td align="left"><?php echo $row_rsodest['card_number']; ?></td>
                                           <td align="left" style="font-weight:bold;">Payment: <?php echo strtoupper($row_rsodest['mode_of_payment']); ?></td>
                                         </tr>
                                         <tr class="baseborder">
                                           <td height="30" align="right" style="text-align: left;font-weight:bold;">
                                           <?php if($row_rsodest['mode_of_payment']=='insurance'){echo "Insurer:";}?>
                                           <?php if($row_rsodest['mode_of_payment']=='company'){echo "Company:";}?>
                                           <?php if($row_rsodest['mode_of_payment']=='staff'){echo "Company:";}?>
                                          </td>
                                           <td align="left">
										   <?php if($row_rsodest['mode_of_payment']=='insurance'){echo strtoupper(getinsurance($row_rsodest['insurance_company']));}?>
                                           <?php if($row_rsodest['mode_of_payment']=='company'){echo strtoupper(getinsurance($row_rsodest['insurance_company']));}?>
                                           <?php if($row_rsodest['mode_of_payment']=='staff'){echo strtoupper($row_rsodest_facility['facility_name']);}?>
										   </td>
                                           <td align="left" style="font-weight:bold;">
										    <?php if($row_rsodest['mode_of_payment']=='insurance'){echo "Mem No:";
											if($row_rsodest['insurance_no']){
											echo strtoupper($row_rsodest['insurance_no']);
											}else{
											echo strtoupper($row_rsodest['insurance_no1']);	
											}
											
											}?>
                                           <?php if($row_rsodest['mode_of_payment']=='company'){echo "Staff No:";
										   
										   
										   if($row_rsodest['insurance_no']){
											echo strtoupper($row_rsodest['insurance_no']);
											}else{
											echo strtoupper($row_rsodest['company_staff_no']);	
											}
										   
										   }?>
                                            <?php if($row_rsodest['mode_of_payment']=='staff'){echo "Staff No:";
											
											 if($row_rsodest['insurance_no']){
											echo strtoupper($row_rsodest['insurance_no']);
											}else{
											echo strtoupper($row_rsodest['medifem_staff_no']);	
											}
											}?>
										   <?php  
										   
										   $_SESSION['member_no']= $row_rsodest['insurance_no'];
										   $_SESSION['ins_company']= $row_rsodest['insurance_company'];
										   
										   ?>
                                             
</td>
                                          </tr>
                                         <tr class="baseborder">
                                           <td height="25" align="right" style="text-align: left;font-weight:bold;">Fullname:</td>
                                           <td align="left"><?php echo strtoupper($row_rsodest['surname']." ".$row_rsodest['othernames']); ?>
                                           </td>
                                           <td align="left" style="font-weight:bold;">Sex: <span style="font-weight:normal;"><?php echo $row_rsodest['sex']; ?></span>
                                             <input type="hidden" id="patient_sex" name="patient_sex" value="<?php echo $row_rsodest['sex']; ?>"></td>
                                         </tr>
                                         <tr class="baseborder">
                                           <td height="25" align="right" style="text-align: left;font-weight:bold;">Date Of Birth:</td>
                                           <td align="left"><?php echo $row_rsodest['datenew']; ?> &nbsp;&nbsp;</td>
                                           <td align="left" style="font-weight:bold;">Age: <span style="font-weight:normal;"><?php echo $row_rsodest['age']; ?></span>
                                             <input type="hidden" id="age" name="age" value="<?php echo $row_rsodest['age']; ?>">
                                             </td>
                                         </tr>
                                         <tr class="baseborder">
                                           <td height="25" align="right" style="text-align: left;font-weight:bold;">Tel:</td>
                                           <td colspan="2" align="left"><?php echo $row_rsodest['tel']; ?></td>
                                           </tr>
                                         <tr class="baseborder">
                                           <td height="25" align="right" style="text-align: left;font-weight:bold;">Employer:</td>
                                           <td colspan="2" align="left"><?php echo $row_rsodest['employer']; $employer=$row_rsodest['employer']; ?></td>
                                           </tr>
                                         </tbody>
                                     </table>

                                     </div>

                                                               <div class="col-xs-5 col-sm-5 col-md-5 col-lg-5">

           <table width="100%" border="0" cellpadding="1" cellspacing="1" class="table">
           <thead>
                    <tr>
                            <th colspan="3" valign="middle" class="baseborder"> CONSULTATION DETAILS </th>
                    </tr>
            </thead>
                              <tbody>
                              <tr class="baseborder">
                                <td height="30" align="right" style="text-align: left;font-weight:bold;">Provider's Name:</td>
                                <td align="left"><?php echo $row_rsodest_facility['facility_name']; ?>
                                  <input type="hidden" id="facility_id" name="facility_id" value="<?php echo $row_rsodest_facility['facility_id']; ?>">
                                  <input type="hidden" id="facility_type" name="facility_type" value="<?php echo $row_rsodest_facility['facility_type']; ?>">
                                  </td>
                              </tr>
                              <tr class="baseborder">
                                <td  height="30" align="right" style="text-align: left;font-weight:bold;">Service Category:</td>
                                <td align="left"><?php echo $row_rsodest['service_category']; ?></td>
                              </tr>
                              <tr class="baseborder">
                                <td height="30" align="right" style="text-align: left;font-weight:bold;">Date of Consultation:</td>
                                <td align="left"><?php echo $row_rsodest['dateconsult']; ?>
                            </td>
                              </tr>
                              <tr class="baseborder">
                                <td height="30" align="right" valign="top" style="text-align: left;font-weight:bold;">Attending Officer:</td>
                                <td align="left" valign="top">
                                    <?php echo $row_rsodest['attending_officer'];?>
                                </td>
                              </tr>
                              <tr class="baseborder">
                                <td height="30" align="right" style="text-align: left;font-weight:bold;">Eye:</td>
                                <td align="left"><?php echo $row_rsodest['eye_optical']; ?></td>
                              </tr>
                              <tr class="baseborder">
                                <td height="30" align="right" valign="top" style="text-align: left;font-weight:bold;">Diagnosis:</td>
                                <td align="left" valign="top">
                                <div id="diagnosis" style="float:left;"><?php //include("medical/list_claim_query_diagnosis.php"); ?></div>
                                    <input type="hidden" id="diagnosis_diseases" name="diagnosis_diseases" value="<?php echo $diseaselisttext; ?>">
                                     <input type="hidden" id="diagnosis_diseases_code" name="diagnosis_diseases_code" value="<?php echo $diseaselistcode; ?>">
                                </td>
                              </tr>
                            </tbody>
                          </table>

                                                               </div>

                                                               <div>
                                                                   <?php include 'view_items_claims_administrative_2.php';?>
                                                               </div>
</div>
</div>
</div>                                     

</div>
</div>
<h6 id="breakmenow"></h6>

<?php } ?>
</body>
</html>