229 lines
11 KiB
PHP
229 lines
11 KiB
PHP
<?php
|
|
include('includes/config/config.php');
|
|
include('includes/functions.php');
|
|
begin();
|
|
|
|
$arr = array("Statutory_Medical_Checkup");
|
|
|
|
for ($x = 0; $x < count($arr); $x++) {
|
|
|
|
// $get_data = "SELECT * from checkup_form where checkup_type_id=(select checkup_type_id from checkup_type where checkup_type_code like '%$arr[$x]%') and (current_status='DRA' or current_status='MRA')";
|
|
|
|
$get_data = "SELECT * from checkup_form where checkup_type_id=(select checkup_type_id from checkup_type where checkup_type_code like '%$arr[$x]%')";
|
|
|
|
error_log("query " . $get_data);
|
|
|
|
$get_result = mysqli_query($conn, $get_data);
|
|
while ($get_row = mysqli_fetch_assoc($get_result)) {
|
|
|
|
$section_ids = $get_row['checkup_section_ids'];
|
|
|
|
$checkUpDate = date('Y-m-d', strtotime($get_row['checkup_date']));
|
|
$Employee_id = $get_row['emp_id'];
|
|
$CheckupId = $get_row['checkup_id'];
|
|
$CheckUpType = $get_row['checkup_type_id'];
|
|
|
|
|
|
$checkup_column_name = "select column_name as name from checkup_parameter where checkup_form_section_id in ($section_ids) and key_health_map_name=(select key_param_id from key_health_reportable_parameter_master where key_param_name='systolic blood pressure' )";
|
|
// error_log("section column getting query " . $checkup_column_name);
|
|
$result_column_name = mysqli_query($conn, $checkup_column_name);
|
|
$row_column_name = mysqli_fetch_assoc($result_column_name);
|
|
|
|
|
|
// for sbp
|
|
$get_param = "select * from checkup_form_key_value where checkup_form_id='" . $get_row['checkup_id'] . "' and checkup_form_key='" . $row_column_name['name'] . "'";
|
|
|
|
$result_param = mysqli_query($conn, $get_param);
|
|
$row_param = mysqli_fetch_assoc($result_param);
|
|
|
|
$sbp = $row_param['checkup_form_value'];
|
|
|
|
error_log("sbp " . $sbp);
|
|
|
|
|
|
$checkup_column_name = "select column_name as name from checkup_parameter where checkup_form_section_id in ($section_ids) and key_health_map_name=(select key_param_id from key_health_reportable_parameter_master where key_param_name='diastolic blood pressure' )";
|
|
// error_log("section column getting query " . $checkup_column_name);
|
|
$result_column_name = mysqli_query($conn, $checkup_column_name);
|
|
$row_column_name = mysqli_fetch_assoc($result_column_name);
|
|
|
|
// for dbp
|
|
$get_param = "select * from checkup_form_key_value where checkup_form_id='" . $get_row['checkup_id'] . "' and checkup_form_key='" . $row_column_name['name'] . "'";
|
|
|
|
$result_param = mysqli_query($conn, $get_param);
|
|
$row_param = mysqli_fetch_assoc($result_param);
|
|
|
|
$dbp = $row_param['checkup_form_value'];
|
|
|
|
error_log("dbp " . $dbp);
|
|
|
|
|
|
$checkup_column_name = "select column_name as name from checkup_parameter where checkup_form_section_id in ($section_ids) and key_health_map_name=(select key_param_id from key_health_reportable_parameter_master where key_param_name='fbs' )";
|
|
// error_log("section column getting query " . $checkup_column_name);
|
|
$result_column_name = mysqli_query($conn, $checkup_column_name);
|
|
$row_column_name = mysqli_fetch_assoc($result_column_name);
|
|
|
|
// for fbs
|
|
$get_param = "select * from checkup_form_key_value where checkup_form_id='" . $get_row['checkup_id'] . "' and checkup_form_key='" . $row_column_name['name'] . "'";
|
|
|
|
$result_param = mysqli_query($conn, $get_param);
|
|
$row_param = mysqli_fetch_assoc($result_param);
|
|
|
|
$fbs = $row_param['checkup_form_value'];
|
|
|
|
error_log("fbs " . $fbs);
|
|
|
|
|
|
$checkup_column_name = "select column_name as name from checkup_parameter where checkup_form_section_id in ($section_ids) and key_health_map_name=(select key_param_id from key_health_reportable_parameter_master where key_param_name='height' )";
|
|
// error_log("section column getting query " . $checkup_column_name);
|
|
$result_column_name = mysqli_query($conn, $checkup_column_name);
|
|
$row_column_name = mysqli_fetch_assoc($result_column_name);
|
|
|
|
// for height
|
|
|
|
$get_param = "select * from checkup_form_key_value where checkup_form_id='" . $get_row['checkup_id'] . "' and checkup_form_key='" . $row_column_name['name'] . "'";
|
|
|
|
$result_param = mysqli_query($conn, $get_param);
|
|
$row_param = mysqli_fetch_assoc($result_param);
|
|
|
|
$height = $row_param['checkup_form_value'];
|
|
|
|
error_log("height " . $height);
|
|
|
|
|
|
$checkup_column_name = "select column_name as name from checkup_parameter where checkup_form_section_id in ($section_ids) and key_health_map_name=(select key_param_id from key_health_reportable_parameter_master where key_param_name='weight' )";
|
|
// error_log("section column getting query " . $checkup_column_name);
|
|
$result_column_name = mysqli_query($conn, $checkup_column_name);
|
|
$row_column_name = mysqli_fetch_assoc($result_column_name);
|
|
|
|
// for weight
|
|
$get_param = "select * from checkup_form_key_value where checkup_form_id='" . $get_row['checkup_id'] . "' and checkup_form_key='" . $row_column_name['name'] . "'";
|
|
|
|
$result_param = mysqli_query($conn, $get_param);
|
|
$row_param = mysqli_fetch_assoc($result_param);
|
|
|
|
$weight = $row_param['checkup_form_value'];
|
|
|
|
error_log("weight " . $weight);
|
|
|
|
|
|
$bmi = 0;
|
|
|
|
if ($height != null && $height != '' && $weight != null && $weight != '') {
|
|
|
|
$height = floatval($height);
|
|
|
|
$weight = floatval($weight);
|
|
|
|
if ($height != 0.0) {
|
|
// $bmi = ($weight / ($height * $height)) * 100 * 100;
|
|
$bmi = $weight / (($height / 100) * ($height / 100));
|
|
|
|
// echo $bmi .'<br>';
|
|
|
|
}
|
|
}
|
|
|
|
$checkup_column_name = "select column_name as name from checkup_parameter where checkup_form_section_id in ($section_ids) and key_health_map_name=(select key_param_id from key_health_reportable_parameter_master where key_param_name='total cholesterol' )";
|
|
// error_log("section column getting query " . $checkup_column_name);
|
|
$result_column_name = mysqli_query($conn, $checkup_column_name);
|
|
$row_column_name = mysqli_fetch_assoc($result_column_name);
|
|
|
|
// for cholestrol
|
|
$get_param = "select * from checkup_form_key_value where checkup_form_id='" . $get_row['checkup_id'] . "' and checkup_form_key='" . $row_column_name['name'] . "'";
|
|
|
|
$result_param = mysqli_query($conn, $get_param);
|
|
$row_param = mysqli_fetch_assoc($result_param);
|
|
|
|
$cholesterol = $row_param['checkup_form_value'];
|
|
|
|
error_log("cholesterol " . $cholesterol);
|
|
|
|
|
|
// for PPBS
|
|
|
|
$checkup_column_name = "select column_name as name from checkup_parameter where checkup_form_section_id in ($section_ids) and key_health_map_name=(select key_param_id from key_health_reportable_parameter_master where key_param_name='ppbs' )";
|
|
// error_log("section column getting query " . $checkup_column_name);
|
|
$result_column_name = mysqli_query($conn, $checkup_column_name);
|
|
$row_column_name = mysqli_fetch_assoc($result_column_name);
|
|
|
|
$get_param = "select * from checkup_form_key_value where checkup_form_id='" . $get_row['checkup_id'] . "' and checkup_form_key='" . $row_column_name['name'] . "'";
|
|
|
|
$result_param = mysqli_query($conn, $get_param);
|
|
$row_param = mysqli_fetch_assoc($result_param);
|
|
|
|
$ppbs = $row_param['checkup_form_value'];
|
|
|
|
error_log("ppbs " . $ppbs);
|
|
|
|
// for HDL
|
|
|
|
$checkup_column_name = "select column_name as name from checkup_parameter where checkup_form_section_id in ($section_ids) and key_health_map_name=(select key_param_id from key_health_reportable_parameter_master where key_param_name='hdl cholesterol' )";
|
|
// error_log("section column getting query " . $checkup_column_name);
|
|
$result_column_name = mysqli_query($conn, $checkup_column_name);
|
|
$row_column_name = mysqli_fetch_assoc($result_column_name);
|
|
|
|
$get_param = "select * from checkup_form_key_value where checkup_form_id='" . $get_row['checkup_id'] . "' and checkup_form_key='" . $row_column_name['name'] . "'";
|
|
|
|
$result_param = mysqli_query($conn, $get_param);
|
|
$row_param = mysqli_fetch_assoc($result_param);
|
|
|
|
$hdl = $row_param['checkup_form_value'];
|
|
|
|
error_log("hdl " . $hdl);
|
|
|
|
// for ldl
|
|
|
|
$checkup_column_name = "select column_name as name from checkup_parameter where checkup_form_section_id in ($section_ids) and key_health_map_name=(select key_param_id from key_health_reportable_parameter_master where key_param_name='ldl cholesterol' )";
|
|
// error_log("section column getting query " . $checkup_column_name);
|
|
$result_column_name = mysqli_query($conn, $checkup_column_name);
|
|
$row_column_name = mysqli_fetch_assoc($result_column_name);
|
|
|
|
$get_param = "select * from checkup_form_key_value where checkup_form_id='" . $get_row['checkup_id'] . "' and checkup_form_key='" . $row_column_name['name'] . "'";
|
|
|
|
$result_param = mysqli_query($conn, $get_param);
|
|
$row_param = mysqli_fetch_assoc($result_param);
|
|
|
|
$ldl = $row_param['checkup_form_value'];
|
|
|
|
error_log("ldl " . $ldl);
|
|
|
|
|
|
// for triglyceride
|
|
|
|
$checkup_column_name = "select column_name as name from checkup_parameter where checkup_form_section_id in ($section_ids) and key_health_map_name=(select key_param_id from key_health_reportable_parameter_master where key_param_name='triglyceride' )";
|
|
// error_log("section column getting query " . $checkup_column_name);
|
|
$result_column_name = mysqli_query($conn, $checkup_column_name);
|
|
$row_column_name = mysqli_fetch_assoc($result_column_name);
|
|
|
|
$get_param = "select * from checkup_form_key_value where checkup_form_id='" . $get_row['checkup_id'] . "' and checkup_form_key='" . $row_column_name['name'] . "'";
|
|
|
|
$result_param = mysqli_query($conn, $get_param);
|
|
$row_param = mysqli_fetch_assoc($result_param);
|
|
|
|
$triglyceride = $row_param['checkup_form_value'];
|
|
|
|
error_log("triglyceride " . $triglyceride);
|
|
|
|
|
|
|
|
// StoreHealthVitals($Employee_id , $height, $weight, $sbp, $dbp, $fbs, $ppbs, $hdl, $ldl, $checkUpDate , '' , $CheckupId);
|
|
// if ($sbp !='' && $dbp !='' && $bmi !='' && $fbs !='' && $cholesterol !='' && $height !='' && $weight !='' && $ppbs !='' && $hdl !='' && $ldl !='' && $triglyceride != '') {
|
|
$health_score = calculateHealthIndex($sbp, $dbp, $bmi, $fbs, $cholesterol, $height, $weight, $ppbs, $hdl, $ldl, $triglyceride);
|
|
|
|
|
|
StoreHealthIndex($checkUpDate, $health_score, $Employee_id, "MED", $CheckUpType , $CheckupId);
|
|
|
|
|
|
$update_health_index = "update checkup_form set health_index='" . $health_score . "' where checkup_id='" . $get_row['checkup_id'] . "'";
|
|
error_log("query for HI " . $update_health_index);
|
|
if (!$result_update = mysqli_query($conn, $update_health_index)) {
|
|
error_log("error while updating " . mysqli_error($conn));
|
|
rollback();
|
|
}
|
|
// }
|
|
|
|
|
|
commit();
|
|
}
|
|
}
|