ESH/cal_health_index_opd.php

31 lines
1.2 KiB
PHP
Raw Permalink Normal View History

2024-10-23 18:28:06 +05:30
<?php
include('includes/config/config.php');
include('includes/functions.php');
begin();
$get_data = "select * from employee_appointment";
$get_result = mysqli_query($conn, $get_data);
while ($get_row = mysqli_fetch_assoc($get_result)) {
$get_param = "select * from employee_appointment where appointment_id='" . $get_row['appointment_id'] . "'";
$result_param = mysqli_query($conn, $get_param);
$row_param = mysqli_fetch_assoc($result_param);
$sbp = $row_param['bp_sbp'];
$dbp = $row_param['bp_dbp'];
$fbs = $row_param['blood_sugar_fbs'];
$bmi = $row_param['bmi'];
$total_cholesterol = $row_param['total_cholesterol'];
error_log("param " . $sbp . " " . $dbp . " " . $fbs . " " . $bmi . " " . $total_cholesterol);
$health_score = calculateHealthIndex($sbp, $dbp, $bmi, $fbs, $total_cholesterol);
$update_health_index = "update employee_appointment set health_index='" . $health_score . "' where appointment_id='" . $get_row['appointment_id'] . "'";
error_log("query for HI for opd " . $update_health_index);
if (!$result_update = mysqli_query($conn, $update_health_index)) {
error_log("error while updating " . mysqli_error($conn));
rollback();
}
commit();
}