<?php 
include('includes/config/config.php');
include_once('log_entry.php');
$where_key = $_REQUEST['key'];
$where_val = $_REQUEST['key_val'];


 if($where_key=='id'){
 	$where_cls ="  where id = '".$where_val."' ";
 	
 }else if($where_key=='aadhar'){
 	$where_cls =" where aadhar_no='".$where_val."' ";
 	
 }else if($where_key=='ecode'){
 	$where_cls =" where emp_code='".$where_val."' ";
 	
 }else{
 	die(mysqli_error($conn));
 }
 
 	$query = "select * from patient_master ".$where_cls;
 	error_log("Patient_Search:".$query);
	if (!$result = @mysqli_query($conn,$query)) {
				die(mysqli_error($conn));
	}
	$data = array();
	if(mysqli_num_rows($result) > 0) {
        while ($row = mysqli_fetch_assoc($result)) {
			//extract($row);
            $data = $row;
         
            $data['emp_photo']=base64_encode($row['emp_photo']);
			$data['emp_sign']=base64_encode($row['emp_sign']);
			$data['doj']=date_format(date_create($row['doj']),"d-M-Y ");
		
           
        }
    }
	 else
    {
        $data['status'] = 200;
        $data['message'] = "Data not found!";
    }
// echo $data;
 echo json_encode($data);
?>