$count_smoking="SELECT max(medical_exam_id),patient_id,smoking from medical_examination where patient_id in (SELECT id FROM patient_master where status='Active' $qry_filter$qry_doj) $qry_date1$qry_date and smoking='1' GROUP by patient_id";
error_log("smoke total : ".$data['smoking']['total']);
$count_hbd="SELECT max(medical_exam_id),patient_id,smoking from medical_examination where patient_id in (SELECT id FROM patient_master where status='Active' $qry_filter$qry_doj) $qry_date1$qry_date and smoking='1' and bmi>=25 and bmi<30 GROUP by patient_id";
error_log("count hbd:".$count_hbd);
$hbd_result=mysqli_query($conn,$count_hbd);
if(mysqli_num_rows($hbd_result)){
$total_hbd_pat=mysqli_num_rows($hbd_result);
}else{
$total_hbd_pat=0;
}
$data['smoking']['hbd_total']=$total_hbd_pat;
error_log("smoke hbd total : ".$data['smoking']['hbd_total']);
$count_tobacco="SELECT max(medical_exam_id),patient_id,tobacco from medical_examination where patient_id in (SELECT id FROM patient_master where status='Active' $qry_filter$qry_doj) $qry_date1$qry_date and tobacco='1' GROUP by patient_id";
error_log("tobacco total : ".$data['tobacco']['total']);
$count_hbd="SELECT max(medical_exam_id),patient_id,tobacco from medical_examination where patient_id in (SELECT id FROM patient_master where status='Active' $qry_filter$qry_doj) $qry_date1$qry_date and tobacco='1' and bmi>=25 and bmi<30 GROUP by patient_id";
error_log("count hbd:".$count_hbd);
$hbd_result=mysqli_query($conn,$count_hbd);
if(mysqli_num_rows($hbd_result)){
$total_hbd_pat=mysqli_num_rows($hbd_result);
}else{
$total_hbd_pat=0;
}
$data['tobacco']['hbd_total']=$total_hbd_pat;
error_log("tobacco hbd total : ".$data['tobacco']['hbd_total']);
$count_alcohol="SELECT max(medical_exam_id),patient_id,alcohol from medical_examination where patient_id in (SELECT id FROM patient_master where status='Active' $qry_filter$qry_doj) $qry_date1$qry_date and alcohol='1' GROUP by patient_id";
error_log("alcohol total : ".$data['alcohol']['total']);
$count_hbd="SELECT max(medical_exam_id),patient_id,alcohol from medical_examination where patient_id in (SELECT id FROM patient_master where status='Active' $qry_filter$qry_doj) $qry_date1$qry_date and alcohol='1' and bmi>=25 and bmi<30 GROUP by patient_id";
error_log("count hbd:".$count_hbd);
$hbd_result=mysqli_query($conn,$count_hbd);
if(mysqli_num_rows($hbd_result)){
$total_hbd_pat=mysqli_num_rows($hbd_result);
}else{
$total_hbd_pat=0;
}
$data['alcohol']['hbd_total']=$total_hbd_pat;
error_log("alcohol hbd total : ".$data['alcohol']['hbd_total']);
$count_smoking_tobacco="SELECT max(medical_exam_id),patient_id,smoking from medical_examination where patient_id in (SELECT id FROM patient_master where status='Active' $qry_filter$qry_doj) $qry_date1$qry_date and smoking='1' and tobacco='1' GROUP by patient_id";
$count_hbd="SELECT max(medical_exam_id),patient_id,smoking from medical_examination where patient_id in (SELECT id FROM patient_master where status='Active' $qry_filter$qry_doj) $qry_date1$qry_date and smoking='1' and tobacco='1' and bmi>=25 and bmi<30 GROUP by patient_id";
$count_smoking_alcohol="SELECT max(medical_exam_id),patient_id,smoking from medical_examination where patient_id in (SELECT id FROM patient_master where status='Active' $qry_filter$qry_doj) $qry_date1$qry_date and smoking='1' and alcohol='1' GROUP by patient_id";
$count_hbd="SELECT max(medical_exam_id),patient_id,smoking from medical_examination where patient_id in (SELECT id FROM patient_master where status='Active' $qry_filter$qry_doj) $qry_date1$qry_date and smoking='1' and alcohol='1' and bmi>=25 and bmi<30 GROUP by patient_id";
$count_tobacco_alcohol="SELECT max(medical_exam_id),patient_id,tobacco from medical_examination where patient_id in (SELECT id FROM patient_master where status='Active' $qry_filter$qry_doj) $qry_date1$qry_date and tobacco='1' and alcohol='1' GROUP by patient_id";
$count_hbd="SELECT max(medical_exam_id),patient_id,tobacco from medical_examination where patient_id in (SELECT id FROM patient_master where status='Active' $qry_filter$qry_doj) $qry_date1$qry_date and tobacco='1' and alcohol='1' and bmi>=25 and bmi<30 GROUP by patient_id";
$count_smoking_tobacco_alcohol="SELECT max(medical_exam_id),patient_id,smoking from medical_examination where patient_id in (SELECT id FROM patient_master where status='Active' $qry_filter$qry_doj) $qry_date1$qry_date and smoking='1' and tobacco='1' and alcohol='1' GROUP by patient_id";
$count_hbd="SELECT max(medical_exam_id),patient_id,smoking from medical_examination where patient_id in (SELECT id FROM patient_master where status='Active' $qry_filter$qry_doj) $qry_date1$qry_date and smoking='1' and tobacco='1' and alcohol='1' and bmi>=25 and bmi<30 GROUP by patient_id";
$qry_date1.=" and year(medical_entry_date) ='".$year2."'";
$qry_filter.=" and year(doj) <= '".$year2."'";
}
//for smoking
$total_hbd_pat=0;
$count_smoking="SELECT max(medical_exam_id),patient_id,smoking from medical_examination where patient_id in (SELECT id FROM patient_master where status='Active' $qry_filter) $qry_date1 and smoking='1' GROUP by patient_id";
error_log("smoke total : ".$data['smoking']['total']);
$count_hbd="SELECT max(medical_exam_id),patient_id,smoking from medical_examination where patient_id in (SELECT id FROM patient_master where status='Active' $qry_filter) $qry_date1 and smoking='1' and bmi>=25 and bmi<30 GROUP by patient_id";
error_log("count hbd:".$count_hbd);
$hbd_result=mysqli_query($conn,$count_hbd);
if(mysqli_num_rows($hbd_result)){
$total_hbd_pat=mysqli_num_rows($hbd_result);
}else{
$total_hbd_pat=0;
}
$data['smoking']['hbd_total']=$total_hbd_pat;
error_log("smoke hbd total : ".$data['smoking']['hbd_total']);
$count_tobacco="SELECT max(medical_exam_id),patient_id,tobacco from medical_examination where patient_id in (SELECT id FROM patient_master where status='Active' $qry_filter) $qry_date1 and tobacco='1' GROUP by patient_id";
error_log("tobacco total : ".$data['tobacco']['total']);
$count_hbd="SELECT max(medical_exam_id),patient_id,tobacco from medical_examination where patient_id in (SELECT id FROM patient_master where status='Active' $qry_filter) $qry_date1 and tobacco='1' and bmi>=25 and bmi<30 GROUP by patient_id";
error_log("count hbd:".$count_hbd);
$hbd_result=mysqli_query($conn,$count_hbd);
if(mysqli_num_rows($hbd_result)){
$total_hbd_pat=mysqli_num_rows($hbd_result);
}else{
$total_hbd_pat=0;
}
$data['tobacco']['hbd_total']=$total_hbd_pat;
error_log("tobacco hbd total : ".$data['tobacco']['hbd_total']);
$count_alcohol="SELECT max(medical_exam_id),patient_id,alcohol from medical_examination where patient_id in (SELECT id FROM patient_master where status='Active' $qry_filter) $qry_date1 and alcohol='1' GROUP by patient_id";
error_log("alcohol total : ".$data['alcohol']['total']);
$count_hbd="SELECT max(medical_exam_id),patient_id,alcohol from medical_examination where patient_id in (SELECT id FROM patient_master where status='Active' $qry_filter) $qry_date1 and alcohol='1' and bmi>=25 and bmi<30 GROUP by patient_id";
error_log("count hbd:".$count_hbd);
$hbd_result=mysqli_query($conn,$count_hbd);
if(mysqli_num_rows($hbd_result)){
$total_hbd_pat=mysqli_num_rows($hbd_result);
}else{
$total_hbd_pat=0;
}
$data['alcohol']['hbd_total']=$total_hbd_pat;
error_log("alcohol hbd total : ".$data['alcohol']['hbd_total']);
$count_smoking_tobacco="SELECT max(medical_exam_id),patient_id,smoking from medical_examination where patient_id in (SELECT id FROM patient_master where status='Active' $qry_filter) $qry_date1 and smoking='1' and tobacco='1' GROUP by patient_id";
$count_hbd="SELECT max(medical_exam_id),patient_id,smoking from medical_examination where patient_id in (SELECT id FROM patient_master where status='Active' $qry_filter) $qry_date1 and smoking='1' and tobacco='1' and bmi>=25 and bmi<30 GROUP by patient_id";
$count_smoking_alcohol="SELECT max(medical_exam_id),patient_id,smoking from medical_examination where patient_id in (SELECT id FROM patient_master where status='Active' $qry_filter) $qry_date1 and smoking='1' and alcohol='1' GROUP by patient_id";
$count_hbd="SELECT max(medical_exam_id),patient_id,smoking from medical_examination where patient_id in (SELECT id FROM patient_master where status='Active' $qry_filter) $qry_date1 and smoking='1' and alcohol='1' and bmi>=25 and bmi<30 GROUP by patient_id";
$count_tobacco_alcohol="SELECT max(medical_exam_id),patient_id,tobacco from medical_examination where patient_id in (SELECT id FROM patient_master where status='Active' $qry_filter) $qry_date1 and tobacco='1' and alcohol='1' GROUP by patient_id";
$count_hbd="SELECT max(medical_exam_id),patient_id,tobacco from medical_examination where patient_id in (SELECT id FROM patient_master where status='Active' $qry_filter) $qry_date1 and tobacco='1' and alcohol='1' and bmi>=25 and bmi<30 GROUP by patient_id";
$count_smoking_tobacco_alcohol="SELECT max(medical_exam_id),patient_id,smoking from medical_examination where patient_id in (SELECT id FROM patient_master where status='Active' $qry_filter) $qry_date1 and smoking='1' and tobacco='1' and alcohol='1' GROUP by patient_id";
$count_hbd="SELECT max(medical_exam_id),patient_id,smoking from medical_examination where patient_id in (SELECT id FROM patient_master where status='Active' $qry_filter) $qry_date1 and smoking='1' and tobacco='1' and alcohol='1' and bmi>=25 and bmi<30 GROUP by patient_id";