84 lines
2.9 KiB
PHP
84 lines
2.9 KiB
PHP
<?php
|
|
include('includes/config/config.php');
|
|
include('includes/functions.php');
|
|
begin();
|
|
$get_data = "select * from checkup_form where checkup_type_id=(select checkup_type_id from checkup_type where checkup_type_code='EXECUTIVE_HEALTH_EXAMINATION')";
|
|
|
|
$get_result = mysqli_query($conn,$get_data);
|
|
while($get_row = mysqli_fetch_assoc($get_result)){
|
|
|
|
|
|
// for sbp
|
|
$get_param = "select * from checkup_form_key_value where checkup_form_id='".$get_row['checkup_id']."' and checkup_form_key='systolic_blood_pressure'";
|
|
|
|
$result_param = mysqli_query($conn,$get_param);
|
|
$row_param = mysqli_fetch_assoc($result_param);
|
|
|
|
$sbp = $row_param['checkup_form_value'];
|
|
|
|
// for dbp
|
|
$get_param = "select * from checkup_form_key_value where checkup_form_id='".$get_row['checkup_id']."' and checkup_form_key='diastolic_blood_pressure'";
|
|
|
|
$result_param = mysqli_query($conn,$get_param);
|
|
$row_param = mysqli_fetch_assoc($result_param);
|
|
|
|
$dbp = $row_param['checkup_form_value'];
|
|
|
|
// for fbs
|
|
$get_param = "select * from checkup_form_key_value where checkup_form_id='".$get_row['checkup_id']."' and checkup_form_key='fbs_1'";
|
|
|
|
$result_param = mysqli_query($conn,$get_param);
|
|
$row_param = mysqli_fetch_assoc($result_param);
|
|
|
|
$fbs = $row_param['checkup_form_value'];
|
|
|
|
// for height
|
|
|
|
$get_param = "select * from checkup_form_key_value where checkup_form_id='".$get_row['checkup_id']."' and checkup_form_key='height'";
|
|
|
|
$result_param = mysqli_query($conn,$get_param);
|
|
$row_param = mysqli_fetch_assoc($result_param);
|
|
|
|
$height = $row_param['checkup_form_value'];
|
|
|
|
// for weight
|
|
$get_param = "select * from checkup_form_key_value where checkup_form_id='".$get_row['checkup_id']."' and checkup_form_key='weight'";
|
|
|
|
$result_param = mysqli_query($conn,$get_param);
|
|
$row_param = mysqli_fetch_assoc($result_param);
|
|
|
|
$weight = $row_param['checkup_form_value'];
|
|
$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;
|
|
}
|
|
|
|
}
|
|
// for cholestrol
|
|
$get_param = "select * from checkup_form_key_value where checkup_form_id='".$get_row['checkup_id']."' and checkup_form_key='total_cholesterol'";
|
|
|
|
$result_param = mysqli_query($conn,$get_param);
|
|
$row_param = mysqli_fetch_assoc($result_param);
|
|
|
|
$cholesterol = $row_param['checkup_form_value'];
|
|
|
|
|
|
|
|
$health_score = calculateHealthIndex($sbp,$dbp,$bmi,$fbs,$cholesterol);
|
|
|
|
$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();
|
|
}
|
|
?>
|