<?php
require_once('Connections/courier.php');
require_once 'functions/functions.php';
$process_claim_no = $_POST['id'];
list ($id, $patient_id ) = explode("@@@", $_POST['id2']);

$visit_info = mysql_fetch_assoc(mysql_query("SELECT * FROM process_claim_no WHERE process_claim_no = '$process_claim_no'"));
$optical_info = mysql_fetch_assoc(mysql_query("SELECT * FROM optical_examination WHERE process_claim_no = '$process_claim_no'"));
$patient_diagnosis = mysql_query("SELECT * FROM claims_details_query_diagnosis WHERE process_claim_no = '$process_claim_no' order by id desc");
$drug_prescriptions = mysql_query("SELECT * FROM claims_details WHERE process_claim_no='$process_claim_no' and item_service='Drugs' order by id desc");
$patient_diagnostics = mysql_query("SELECT * FROM claims_details WHERE process_claim_no='$process_claim_no' and (item_service='Laboratory' or item_service='Radiology') order by id desc;");
$patient_files = mysql_query("SELECT * FROM patient_file_attachments WHERE process_claim_no = '$process_claim_no' ORDER BY id ASC");
$medical_procedures = mysql_query("SELECT * FROM claims_details WHERE process_claim_no = '$process_claim_no' AND item_service='Optical'");
$spectacle_prescriptions = mysql_query("SELECT * FROM claims_details WHERE process_claim_no = '$process_claim_no' AND (item_service_type='Optical Frame' OR item_service_type='Optical Lens') ORDER BY item_service_type");


//NEXT PATIENT RECORDS
$next = mysql_fetch_assoc(mysql_query("SELECT * FROM process_claim_no WHERE patient_id = '$patient_id' AND id = (SELECT MIN(id) FROM process_claim_no WHERE patient_id = '$patient_id' AND id > $id)"));
//PREVIUOS RECORDS
$previous = mysql_fetch_assoc(mysql_query("SELECT * FROM process_claim_no WHERE patient_id = '$patient_id' AND id = (SELECT MAX(id) FROM process_claim_no WHERE patient_id = '$patient_id' AND id < $id)"));

$row_rsodest_patient = mysql_fetch_assoc(mysql_query("SELECT * FROM patient_information WHERE id = '$patient_id'"));

$drugHistory = mysql_query("SELECT * FROM claims_details WHERE patient_no = '".$visit_info['patient_no']."' AND item_service = 'Drugs'");



$optical_hitory = mysql_fetch_assoc(mysql_query("SELECT * FROM medical_history WHERE process_claim_no = '$process_claim_no'"));
$Hypertension = $optical_hitory['Hypertension'];
$Sicle_Cell_Disease = $optical_hitory['Sicle_Cell_Disease'];
$Hyperlipidemia = $optical_hitory['Hyperlipidemia'];
$Diabetes_Mellitus = $optical_hitory['Diabetes_Mellitus'];
$Asthma = $optical_hitory['Asthma'];
$others = $optical_hitory['others'];
$left_visual = $optical_hitory['left_visual'];
$right_visual = $optical_hitory['right_visual'];

?>

<form name="form" method="post" class="context">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true" id="closemodal"></button>
        <h4 class="modal-title"><b>Consultation Details - <?php echo $row_rsodest_patient['surname'].' '.$row_rsodest_patient['othernames']; ?></b><br>
            <div style="width: 350px;display:inline">
               
                <div class="" style="">
            <div style="float: left">
                 <?php if(!empty($previous['process_claim_no'])){ ?>
                <button onclick="getMedicalHistoryDetails('get_medical_history_details_optical','<?php echo $previous['process_claim_no']; ?>','<?php echo $previous['id'].'@@@'.$previous['patient_id']; ?>');return false;" class="btn green input-circle" style="border-left:2px solid white"> <i class="fa fa-angle-double-left"></i> Prev </button>  
                 <?php } ?>
            </div> &nbsp;
            <div style="float: right">
                <?php if(!empty($next['process_claim_no'])){ ?>
                <button onclick="getMedicalHistoryDetails('get_medical_history_details_optical','<?php echo $next['process_claim_no']; ?>','<?php echo $next['id'].'@@@'.$next['patient_id']; ?>');return false;" class="btn green input-circle" style="border-right:2px solid white"> Next <i class="fa fa-angle-double-right"></i></button>  
                <?php } ?>
            </div>
        </div>
                
                <!--<input style="width: 350px;margin-right:20px;" class="form-control pull-right" type="text" name="keyword" id="keyword" placeholder="Search To Highlight On this Page">-->
            
            </div>
        </h4>
    </div>
    <div class="modal-body" style="">
        <div class="row">
            <div class="col-md-12">
                <div class="profile-userpic" id="second_profile_pic" style="position: absolute;z-index: 1000;right: 40px;top: -10px;cursor: pointer;">
                    <?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:180px;border: 5px solid #e7ecf1;" alt=""> 
                </div>
                
                <div class="row">
                    <div class="col-md-12" style="padding-top:10px">
                        <label class="col-md-3 bold">
                            Visit Date
                        </label>
                        <div class="col-md-9">
                            <?php echo date('jS F, Y g:m a', strtotime($visit_info['datetimeadded'])); ?>
                        </div>
                    </div>
                </div><hr>
                
                <div class="row"  >
                    <div class="col-md-12" style="padding-top:10px">
                        <label class="col-md-3 bold">
                           Attending Officer
                        </label>
                        <div class="col-md-9">
                            <?php echo $visit_info['attending_officer'];?>
                        </div>
                    </div>
                </div><hr>
                
                <div class="row" style="display:none;">
                    <div class="col-md-12" style="padding-top:10px">
                        <label class="col-md-3 bold">
                           Service Category
                        </label>
                        <div class="col-md-9">
                           <?php echo $visit_info['area_specialisation'];?>
                        </div>
                    </div>
                </div>
                
                <div class="row"  >
                    <div class="col-md-12" style="padding-top:10px">
                        <label class="col-md-3 bold">
                        Medical/Consultation Note
                        </label>
                        <div class="col-md-9">
                           <?php echo $visit_info['medical_consultation_note'];?>
                        </div>
                    </div>
                </div><hr>
                
         <div class="row"  >
             <div class="col-md-12" >
                 <label class="col-md-3 bold">
                     Optical Examinations
                 </label>
                 <div class="col-md-9"  style="background-color: #FFFFFF;">
                     <div class="row" style="display:none;">
                         <div class="col-md-12">
                             <label class="col-md-3 bold">
                                 Patient's Complaints
                             </label>
                             <div class="col-md-9">
                                 <?php echo $optical_info['patient_complaints']; ?>
                             </div>
                         </div>
                     </div><hr>
                     <div class="row">
                         <div class="col-md-12">
                             <label class="col-md-3 bold">
                                 VA WoRx & VA WRx/PH
                             </label>
                             <div class="col-md-9">
                                 <table class="table table-bordered" style="width:100%">
                        <thead>
                            <tr>
                                <th style="width:40%;text-align: center"> OD </th>
                                <th style="width:20%;"> &nbsp; </th>
                                <th style="width:40%;text-align: center"> OS </th>
                            </tr>
                        </thead>
                        
                        <tbody>
                            <tr>
                                <td style="text-align: center;background-color: yellow"> <?php echo $optical_info['od_worx']; ?> </td>
                                <td style="font-weight: bold;text-align: center;"> VA WoRx </td>
                                <td style="text-align: center;background-color: yellow"> <?php echo $optical_info['os_worx']; ?> </td>
                            </tr>
                            
                            <tr>
                                <td style="text-align: center;background-color: yellow"><?php echo $optical_info['od_wrx']; ?> </td>
                                <td style="font-weight: bold;text-align: center;"> VA WRx/PH </td>
                                <td style="text-align: center;background-color: yellow"> <?php echo $optical_info['os_wrx']; ?> </td>
                            </tr>
                            
                        </tbody>
                    </table>
                             </div>
                         </div>
                     </div><hr>
                     <div class="row">
                         <div class="col-md-12">
                             <label class="col-md-3 bold">
                                 Eye Examination
                             </label>
                             <div class="col-md-9">
                                 <table class="table table-bordered" style="width:100%">
                        <thead>
                            <tr>
                                <th style="width:40%;text-align: center"> OD </th>
                                <th style="width:20%;"> &nbsp; </th>
                                <th style="width:40%;text-align: center"> OS </th>
                            </tr>
                        </thead>
                        
                        <tbody>
                            <tr>
                                <td style="text-align: center;background-color: yellow"> <?php echo $optical_info['od_lids']; ?> </td>
                                <td style="font-weight: bold;text-align: center;"> LIDS </td>
                                <td style="text-align: center;background-color: yellow"> <?php echo $optical_info['os_lids']; ?> </td>
                            </tr>
                            
                            <tr>
                                <td style="text-align: center;background-color: yellow"> <?php echo $optical_info['od_conjunctiva']; ?> </td>
                                <td style="font-weight: bold;text-align: center;"> CONJUNCTIVA </td>
                                <td style="text-align: center;background-color: yellow"> <?php echo $optical_info['os_conjunctiva']; ?> </td>
                            </tr>
                           
                            <tr>
                                <td style="text-align: center;background-color: yellow"> <?php echo $optical_info['od_cornea']; ?> </td>
                                <td style="font-weight: bold;text-align: center;"> CORNEA </td>
                                <td style="text-align: center;background-color: yellow"> <?php echo $optical_info['os_cornea']; ?> </td>
                            </tr>
                            
                            <tr>
                                <td style="text-align: center;background-color: yellow"> <?php echo $optical_info['od_ac']; ?> </td>
                                <td style="font-weight: bold;text-align: center;"> A/C </td>
                                <td style="text-align: center;background-color: yellow"> <?php echo $optical_info['os_ac']; ?> </td>
                            </tr>
                            
                            <tr>
                                <td style="text-align: center;background-color: yellow"> <?php echo $optical_info['od_iris']; ?> </td>
                                <td style="font-weight: bold;text-align: center;"> IRIS </td>
                                <td style="text-align: center;background-color: yellow"> <?php echo $optical_info['os_iris']; ?> </td>
                            </tr>
                            
                            <tr>
                                <td style="text-align: center;background-color: yellow"> <?php echo $optical_info['od_lens']; ?> </td>
                                <td style="font-weight: bold;text-align: center;"> LENS </td>
                                <td style="text-align: center;background-color: yellow"> <?php echo $optical_info['os_lens']; ?> </td>
                            </tr>
                            
                            <tr>
                                <td style="text-align: center;background-color: yellow"> <?php echo $optical_info['od_vireous']; ?></td>
                                <td style="font-weight: bold;text-align: center;"> VITREOUS </td>
                                <td style="text-align: center;background-color: yellow"> <?php echo $optical_info['os_vireous']; ?> </td>
                            </tr>
                            
                            <tr>
                                <td style="text-align: center;background-color: yellow"> <?php echo $optical_info['od_fundus']; ?> </td>
                                <td style="font-weight: bold;text-align: center;"> FUNDUS </td>
                                <td style="text-align: center;background-color: yellow"> <?php echo $optical_info['os_fundus']; ?> </td>
                            </tr>
                            
                            <tr>
                                <td style="text-align: center;background-color: yellow"> <?php echo $optical_info['od_disc']; ?> </td>
                                <td style="font-weight: bold;text-align: center;"> DISC </td>
                                <td style="text-align: center;background-color: yellow"> <?php echo $optical_info['os_disc']; ?> </td>
                            </tr>
                            
                            <tr>
                                <td style="text-align: center;background-color: yellow"> <?php echo $optical_info['od_cd_ratio']; ?> </td>
                                <td style="font-weight: bold;text-align: center;"> CD/RATIO </td>
                                <td style="text-align: center;background-color: yellow"> <?php echo $optical_info['os_cd_ratio']; ?> </td>
                            </tr>
                            
                            <tr>
                                <td style="text-align: center;background-color: yellow"> <?php echo $optical_info['od_vessels']; ?> </td>
                                <td style="font-weight: bold;text-align: center;"> VESSELS </td>
                                <td style="text-align: center;background-color: yellow"> <?php echo $optical_info['os_vessels']; ?> </td>
                            </tr>
                            
                            <tr>
                                <td style="text-align: center;background-color: yellow"> <?php echo $optical_info['od_iop']; ?> </td>
                                <td style="font-weight: bold;text-align: center;"> INTRAOCULAR PRESSURE (IOP) </td>
                                <td style="text-align: center;background-color: yellow"> <?php echo $optical_info['os_iop']; ?> </td>
                            </tr>
                        </tbody>
                    </table>
                             </div>
                         </div>
                     </div><hr>
                     <div class="row">
                         <div class="col-md-12">
                             <label class="col-md-3 bold">
                                 Refraction
                             </label>
                             <div class="col-md-9">
                                 <table class="table table-bordered">
                        <thead>
                            <tr>
                                <th>&nbsp;</th>
                                <th style="text-align: center"> Sphere </th>
                                <th style="text-align: center"> Cylinder </th>
                                <th style="text-align: center"> Axis </th>
                                <th style="text-align: center"> VA </th>
                                <th style="text-align: center"> Add </th>
                                <th style="text-align: center"> VA </th>
                                <th style="text-align: center"> PD </th>
                            </tr>
                        </thead>
                        <tbody>
                            
                            <tr>
                                <td> <label> OD </label> </td> 
                                <td style="text-align: center;background-color: yellow"> <?php echo $optical_info['od_sphere']; ?> </td> 
                                <td style="text-align: center;background-color: yellow"> <?php echo $optical_info['od_cylinder']; ?> </td> 
                                <td style="text-align: center;background-color: yellow"> <?php echo $optical_info['od_axis']; ?> </td> 
                                <td style="text-align: center;background-color: yellow"> <?php echo $optical_info['od_va']; ?> </td> 
                                <td style="text-align: center;background-color: yellow"> <?php echo $optical_info['od_add']; ?> </td> 
                                <td style="text-align: center;background-color: yellow"> <?php echo $optical_info['od_va2']; ?> </td> 
                                <td style="text-align: center;background-color: yellow"> <?php echo $optical_info['od_pd']; ?> </td> 
                            </tr>
                            
                            <tr>
                                <td> <label> OS </label> </td> 
                                <td style="text-align: center;background-color: yellow"> <?php echo $optical_info['os_sphere']; ?> </td> 
                                <td style="text-align: center;background-color: yellow"> <?php echo $optical_info['os_cylinder']; ?> </td> 
                                <td style="text-align: center;background-color: yellow"> <?php echo $optical_info['os_axis']; ?> </td> 
                                <td style="text-align: center;background-color: yellow"> <?php echo $optical_info['os_va']; ?> </td> 
                                <td style="text-align: center;background-color: yellow"> <?php echo $optical_info['os_add']; ?> </td> 
                                <td style="text-align: center;background-color: yellow"> <?php echo $optical_info['os_va2']; ?> </td> 
                                <td style="text-align: center;background-color: yellow"> <?php echo $optical_info['os_pd']; ?> </td> 
                            </tr>
                            
                        </tbody>
                    </table>
                             </div>
                         </div>
                     </div><hr>
                     <div class="row">
                         <div class="col-md-12">
                             <label class="col-md-3 bold">
                                 Lens Information
                             </label>
                             <div class="col-md-9">
                             <?php
                             $patient_lens_type = mysql_fetch_assoc(mysql_query("SELECT lens_type FROM patient_lens_type WHERE process_claim_no='$process_claim_no'"));
                             echo '<b>'. $patient_lens_type['lens_type']; ?> - Additions (<span id="lens_description_wrapper2"><?php echo PatientLensAddition($process_claim_no);  ?>)</span> </b>
                             </div>
                         </div>
                     </div><hr>
                     <div class="row">
                         <div class="col-md-12">
                             <label class="col-md-3 bold">
                                 Contact Lens Prescription
                             </label>
                             <div class="col-md-9">
                             <table class="table table-bordered">
                        <thead>
                            <tr>
                                <th> R </th>
                                <th> L </th>
                                <th> Base Curve </th>
                                <th> Diameter </th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                                <td><?php echo $optical_info['r_eye']; ?></td> 
                                <td><?php echo $optical_info['l_eye']; ?></td> 
                                <td><?php echo $optical_info['base_curve']; ?> </td> 
                                <td><?php echo $optical_info['diameter']; ?> </td> 
                            </tr>
                        </tbody>
                    </table>
                            </div>
                         </div>
                     </div><hr>
                     <div class="row">
                         <div class="col-md-12">
                             <label class="col-md-3 bold">
                                 Additional Note/Comment
                             </label>
                             <div class="col-md-9">
                                 <?php echo $visit_info['additional_note']; ?>
                             </div>
                         </div>
                     </div><hr>
                     <div class="row" style="display:none;">
                         <div class="col-md-12">
                             <label class="col-md-3 bold">
                                 Other Examinations
                             </label>
                             <div class="col-md-9">
                                 <?php echo $optical_info['other_examination']; ?>
                             </div>
                         </div>
                     </div>
                     <div class="row" style="display:none;">
                         <div class="col-md-12">
                             <label class="col-md-3 bold">
                                 Plan / Treatment
                             </label>
                             <div class="col-md-9">
                                 <?php echo $optical_info['plan_treatment']; ?>
                             </div>
                         </div>
                     </div>
                 </div>
             </div>
         </div>
                 <hr>
             
         <div class="row">
             <div class="col-md-12" style="padding-top:10px">
                 <label class="col-md-3 bold">
                     Patient's Diagnosis
                 </label>
                 <div class="col-md-9">
                     <?php 
                     $i = 1;
                     while($row = mysql_fetch_assoc($patient_diagnosis)){
                         echo '<b>('.$i.')</b> ' . $row['disease_name'].' ';if($row['status'] == 'confirmed'){ ?> <i style="font-size: 12px;color:blue;">Confirmed</i> <i id="status_<?php echo $row['id'];?>" style="font-size: 12px;color:blue;" class="icon-ok"></i> <?php }  
                     $i++; }?>
                 </div>
             </div>
         </div><hr>
         
         <div class="row"  >
             <div class="col-md-12" style="padding-top:10px">
                 <label class="col-md-3 bold">
                     Drug Prescriptions
                 </label>
                 <div class="col-md-9">
                     <?php 
                     $i=1;
                     while($row = mysql_fetch_assoc($drug_prescriptions)){
                        echo '<b>('.$i.')</b> ' .$row['item'].', '; 
                     $i++; }?>
                 </div>
             </div>
         </div><hr>
         
         <div class="row">
             <div class="col-md-12" style="padding-top:10px">
                 <label class="col-md-3 bold">
                     Optical Diagnostics
                 </label>
                 <div class="col-md-9">
                     <?php 
                     $i=1;
                     while($row = mysql_fetch_assoc($patient_diagnostics)){
                        echo '<b>('.$i.')</b> ' .$row['item'].', '; 
                     $i++; }?>
                 </div>
             </div>
         </div><hr>
         
         <div class="row"  >
             <div class="col-md-12" style="padding-top:10px">
                 <label class="col-md-3 bold">
                     File Attachments
                 </label>
                 <div class="col-md-9">
                       <div class="mt-comments" style="cursor: pointer;">
                                        <?php
                                        $count_files = mysql_num_rows($patient_files);
                                        if($count_files > 0){
                                          $total_entry = $count_files;
                                          $file_identifier = 1;
                                          while($row_files = mysql_fetch_assoc($patient_files)){
                                            $path_info = pathinfo($row_files['file_path']);
                                            $ext = $path_info['extension'];
                                            $valid_formats = array("jpg","png","gif","bmp","icon");
                                                            $valid_formats2 = array("docx","doc");
                                                            $valid_formats3 = array("xlsx","xls");
                                                            $valid_formats4 = array("pptx");
                                                            $valid_formats5 = array("csv");
                                                            $valid_formats6 = array("xml");
                                                            $valid_formats7 = array("pdf");
                                                            $valid_formats8 = array("txt"); ?>
                                        <div id="file_attachment_wrapper_<?php echo $file_identifier;?>" class="mt-comment" style="background-color: #FAFAFA;border: 1px solid #eee;">    
                                        <div class="mt-comment-img">
                                                <?php
                                                 if(in_array(strtolower($ext),$valid_formats)) { ?>
                                                                    <img src="<?php echo $row_files['file_path'];?>" style="height: 50px;width:50px;">
                                                            <?php      
                                                             }
                                                            else if(in_array(strtolower($ext),$valid_formats2)) { ?>
                                                                    <img src="<?php echo '../'.FOLDER_NAME;?>images/word-iconx.png" style="width: 30px;height: 30px;">
                                                            <?php      
                                                             }
                                                            else if(in_array(strtolower($ext),$valid_formats3)) { ?>
                                                                    <img src="<?php echo '../'.FOLDER_NAME;?>images/excel-iconx.png" style="width: 30px;height: 30px;">
                                                            <?php      
                                                             }
                                                            else if(in_array(strtolower($ext),$valid_formats4)) { ?>
                                                                    <img src="<?php echo '../'.FOLDER_NAME;?>images/pp-iconx.png" style="width: 30px;height: 30px;">
                                                            <?php      
                                                             }
                                                            else if(in_array(strtolower($ext),$valid_formats5)) { ?>
                                                                    <img src="<?php echo '../'.FOLDER_NAME;?>images/csv-iconx.png" style="width: 30px;height: 30px;">
                                                            <?php      
                                                             }
                                                            else if(in_array(strtolower($ext),$valid_formats6)) { ?>
                                                                    <img src="<?php echo '../'.FOLDER_NAME;?>images/xml-iconx.png" style="width: 30px;height: 30px;">
                                                            <?php      
                                                             }
                                                            else if(in_array(strtolower($ext),$valid_formats7)) { ?>
                                                                    <img src="<?php echo '../'.FOLDER_NAME;?>images/PDFx.png" style="width: 30px;height: 30px;">
                                                            <?php      
                                                             }
                                                            else if(in_array(strtolower($ext),$valid_formats8)) { ?>
                                                                    <img src="<?php echo '../'.FOLDER_NAME;?>images/txt-iconx.png" style="width: 30px;height: 30px;">
                                                            <?php      
                                                             }else{ ?>
                                                                 <img src="<?php echo '../'.FOLDER_NAME;?>images/file-iconx.png" style="width: 30px;height: 30px;">
                                                                    Other File
                                                            <?php } ?>
                                            </div>
                                            <div class="mt-comment-body">
                                                <div class="mt-comment-info">
                                                    <span class="mt-comment-author"> 
                                                        <a href="<?php echo $row_files['file_path'];?>" target="_blank"> <?php echo strtoupper($row_files['filename']);?> </a>
                                                    </span>
                                                    <span class="mt-comment-date"> <?php echo date('jS F, Y g:ia', strtotime($row_files['date_time'])); ?> </span>
                                                </div>
                                                <div class="mt-comment-text">TAGS : <?php echo $row_files['tags'];?></div>
                                            </div>
                                          </div>
                                        <?php $file_identifier++;  }  
                                        }?>
                                    </div>
                 </div>
             </div>
         </div> <hr>
                
                <div class="row">
             <div class="col-md-12" style="padding-top:10px">
                 <label class="col-md-3 bold">
                    Spectacle Prescriptions
                 </label>
                 <div class="col-md-9">
                     <?php 
                     $i=1;
                     while($row = mysql_fetch_assoc($spectacle_prescriptions)){
                        echo '<b>('.$i.')</b> ' .$row['item'].' <br> '; 
                      $i++;}?>
                 </div>
             </div>
         </div><hr>
                
         <div class="row">
             <div class="col-md-12" style="padding-top:10px">
                 <label class="col-md-3 bold">
                     Optical Procedures
                 </label>
                 <div class="col-md-9">
                     <?php 
                     $i=1;
                     while($row = mysql_fetch_assoc($medical_procedures)){
                        echo '<b>('.$i.')</b> ' .$row['item'].', '; 
                      $i++;}?>
                 </div>
             </div>
         </div><hr>
         
<div class="row">
 <div class="col-md-12" style="padding-top:10px">
     <label class="col-md-3 bold">
         Medical History
     </label>
     <div class="col-md-9">
        <div class="row">
           <div class="col-md-4" style="">

            <?php if (is_null($Hypertension) || $Hypertension == '') {
            }else{?>
              <input type="checkbox" name="Hypertension" value="Hypertension" id="Hypertension" <?php if (is_null($Hypertension) || $Hypertension == '') {
              }else{
                  echo "checked";
              } ?>>
              <label>Hypertension</label><br>
          <?php } ?>



          <?php if (is_null($Diabetes_Mellitus) || $Diabetes_Mellitus == '') {
          }else{?>
             <input type="checkbox" name="Diabetes_Mellitus" value="Diabetes Mellitus" id="Diabetes_Mellitus" <?php if (is_null($Diabetes_Mellitus) || $Diabetes_Mellitus == '') {
             }else{
              echo "checked";
          } ?>>
          <label>Diabetes Mellitus</label>
      <?php } ?>

  </div>

  <div class="col-md-4" style="">
    <?php if (is_null($Sicle_Cell_Disease) || $Sicle_Cell_Disease == '') {
    }else{?>
       <input type="checkbox" name="Sicle_Cell_Disease" value="Sicle Cell Disease" id="Sicle_Cell_Disease" <?php if (is_null($Sicle_Cell_Disease) || $Sicle_Cell_Disease == '') {
       }else{
          echo "checked";
      } ?>>
      <label>Sicle Cell Disease</label><br>
  <?php } ?>




  <?php if (is_null($Asthma) || $Asthma == '') {
  }else{?>
    <input type="checkbox" name="Asthma" value="Asthma" id="Asthma" <?php if (is_null($Asthma) || $Asthma == '') {
    }else{
      echo "checked";
  } ?>>
  <label>Asthma</label>
<?php } ?>

</div>

<div class="col-md-4" style="">

    <?php if (is_null($Hyperlipidemia) || $Hyperlipidemia == '') {
    }else{?>
      <input type="checkbox" name="Hyperlipidemia" value="Hyperlipidemia" id="Hyperlipidemia" <?php if (is_null($Hyperlipidemia) || $Hyperlipidemia == '') {
      }else{
          echo "checked";
      } ?>>
      <label>Hyperlipidemia</label><br>
  <?php } ?>


  <?php if (is_null($others) || $others == '') {
  }else{?>
      <input type="checkbox" name="OtherHistory" value="Other" id="OtherHistory35" onclick="showOthers('OtherHistory35','OtherHistory12');" <?php if (is_null($others) || $others == '') {
      }else{
          echo "checked";
      } ?>>
      <label>Other </label>
  <?php } ?>


</div>
<br>
<br>
<?php if (is_null($others) || $others == '') { ?>
<?php }else{?>

    <textarea name="OtherHistory12" id="OtherHistory78" class="form-control" rows="5" <?php if(is_null($others) || $others == ''){ echo 'style="display: none;"';} ?>  placeholder="Other History"><?php echo $others; ?></textarea>

<?php } ?>

</div>
</div>
</div>
</div><hr>

<div class="row">
 <div class="col-md-12" style="padding-top:10px">
     <label class="col-md-3 bold">
         Drug History
     </label>
     <div class="col-md-9">
         <?php
         $i=1;
         while($row = mysql_fetch_assoc($drugHistory)){
            echo '<b>('.$i.')</b> ' .$row['item'].', ';
            $i++;}?>
        </div>
    </div>
</div><hr>

<div class="row">
 <div class="col-md-12" style="padding-top:10px">
     <label class="col-md-3 bold">
         Visual Acuity
     </label>
     <div class="col-md-9">
         <div class="row">
             <div class="col-md-4">
                <b>Left</b><br>
                <?php echo $left_visual ?>
            </div>

            <div class="col-md-4">
                <b>Right</b><br>
                <?php echo $right_visual ?>
            </div>
        </div>
    </div>
</div>
</div><hr>


<div class="row">
 <div class="col-md-12" style="padding-top:10px">
     <label class="col-md-3 bold">
         Lab Result
     </label>
     <div class="col-md-9">
         <?php
         function getLabResult($itemId, $process_claim_no, $courier){
            $query = mysql_fetch_assoc(mysql_query("SELECT result FROM diagnostic_result WHERE item_id = '$itemId' AND process_claim_no = '$process_claim_no'"));
            return $item = $query['result'];
        }

        function getLabResultImage($itemId, $process_claim_no, $courier){
            $query = mysql_fetch_assoc(mysql_query("SELECT imagepath FROM diagnostic_result WHERE item_id = '$itemId' AND process_claim_no = '$process_claim_no'"));
           //echo "SELECT result FROM diagnostic_result WHERE item_id = '$itemId' AND process_claim_no = '$process_claim_no'";
            return $imagepath = $query['imagepath'];
        }
        //////// get labs prescripbed for the patient ///////////////////////
        $servicetype = "";
        $servicetype=$servicetype."item_service='Laboratory' or item_service='Radiology' or ";
        $servicetype=" (".substr($servicetype,0,-4).") ";
        $queryItems = "SELECT *,a.item AS item_name,a.provider_item_id AS item_idd FROM claims_details a LEFT JOIN diagnostic_result b ON b.process_claim_no = a.process_claim_no WHERE (a.item_service='Laboratory' or a.item_service='Radiology') and a.process_claim_no = '$process_claim_no'  GROUP BY a.item  ORDER BY a.item DESC limit 0,100";
        $resultItems = mysql_query($queryItems) or die(mysql_error());
        $totalRows = mysql_num_rows($resultItems);
        if ($totalRows > 0) {?>
            <div class="row">
             <table class="table table-bordered" border="0">
                <tr>
                    <th>Diagnostic</th>
                    <th>Result</th>
                    <th>File</th>
                </tr>
                <?php while ($resultItems1 = mysql_fetch_assoc($resultItems)) {
                   $itemIdd = $resultItems1['item_idd'];
                   ?>
                   <tr>

                    <td style="width: 200px"><?php echo $resultItems1['item_name']; ?></td>

                    <td style="width: 500px">
                        <label>
                           <?php echo strtoupper(getLabResult($itemIdd, $process_claim_no, $courier)); ?>
                       </label>
                   </td>

                   <td style="">

                    <?php  $imagePath = getLabResultImage($itemIdd, $process_claim_no, $courier); ?>
                    <img src="<?php echo $imagePath;?>" style="width: 30px;height: 30px;">
                    <div class="mt-comment-body">
                    <div class="mt-comment-info">
                        <span class="mt-comment-author">
                            <a href="<?php echo $imagePath;?>" target="_blank"> <?php echo strtoupper($imagePath);?> </a>
                        </span>

                    </div>

                </div>
                    <!-- <div class="row">
                     <div class="demo-gallery">
                      <ul id="lightgallery" class="list-unstyled row">
                       <li style="list-style-type: none;" class="col-xs-3 col-sm-4 col-md-3" data-responsive="images/lab/<?php echo $image ?> 375, images/lab/<?php echo $image ?> 480, images/lab/<?php echo $image ?> 800" data-src="images/lab/<?php echo $image ?>" data-sub-html="<h4></h4><p></p>">
                        <a href="">
                            <img style="height:20px" class="img-responsive" src="images/lab/<?php echo $image ?>">
                        </a>
                    </li>
                </ul>
            </div>
        </div> -->


    </td>

</tr>
<?php }  ?>
</table>





</div>
<?php }  ?>
</div>
</div>
</div><hr>

         <div class="row">
             <div class="col-md-12">
                 <label class="col-md-3 bold">
                     Patient Status
                 </label>
                 <div class="col-md-9">
                     <?php 
                     if ($visit_info['consulting_room_status'] == 'discharged' || $visit_info['consulting_room_status'] == 'discharged_review') {
                         if ($visit_info['consulting_room_status'] == 'discharged_review') {
                             $today = strtotime(date('Y-m-d'));
                             $review_date = strtotime($visit_info['review_date']);
                             if ($today < $review_date) {
                                 echo '<b>DISCHARGED TO COME FOR REVIEW IN ' . strtoupper(timeAgo($visit_info['review_date'])) . ' TIME </b>';
                             } else if ($today > $review_date) {
                                 echo '<span style="color:red;font-weight:bold;">PATIENT WAS SUPPOSE TO REPORT FOR A REVIEW ' . strtoupper(timeAgo($visit_info['review_date'])) . ' AGO. </span>';
                             } else if ($today == $review_date) {
                                 echo '<b>PATIENT HAS A REVIEW TODAY</b>';
                             }
                         } else {
                             echo '<b>DISCHARGED COMPLETELY</b>';
                         }
                     } else if ($visit_info['consulting_room_status'] == 'referred') {
                         echo '<b>REFERRED TO : ' . $visit_info['referred_hospital'].'</b>';
                     } else if ($visit_info['consulting_room_status'] == 'pending_observation') {
                         echo '<b>DETAINED FOR OBSERVATION</b>';
                     } else if ($visit_info['consulting_room_status'] == 'pending_diagnostic') {
                         echo '<b>AWAITING DIAGNOSTIC RESULTS</b>';
                     } 
                     
                     ?>
                     
                 </div>
             </div>
         </div>
                
                
            </div>
        </div>
        
        <div class="modal-footer" style="">
            <div style="float: left">
                 <?php if(!empty($previous['process_claim_no'])){ ?>
                <button onclick="getMedicalHistoryDetails('get_medical_history_details_optical','<?php echo $previous['process_claim_no']; ?>','<?php echo $previous['id'].'@@@'.$previous['patient_id']; ?>');return false;" class="btn green input-circle" style="border-left:2px solid white"> <i class="fa fa-angle-double-left"></i> Prev </button>  
                 <?php } ?>
            </div>
            <div style="float: right">
                <?php if(!empty($next['process_claim_no'])){ ?>
                <button onclick="getMedicalHistoryDetails('get_medical_history_details_optical','<?php echo $next['process_claim_no']; ?>','<?php echo $next['id'].'@@@'.$next['patient_id']; ?>');return false;" class="btn green input-circle" style="border-right:2px solid white"> Next <i class="fa fa-angle-double-right"></i></button>  
                <?php } ?>
            </div>
        </div>

    </div>
</form>

<script type="text/javascript">
$(function() {
 var mark = function() {
   var keyword = $("input[name='keyword']").val();
   var options = {"separateWordSearch": false,"ignoreJoiners": false,
    "acrossElements": true,"each": function(element) {
        setTimeout(function() {
          $(element).addClass("animate");
        }, 250);
      }};
   $(".context").unmark().mark(keyword, options);
 };
 $("input[name='keyword']").on("input", mark);

$('#lightgallery').lightGallery({
    cssEasing: 'cubic-bezier(0.680, -0.550, 0.265, 1.550)'
});

});



</script>
