83 lines
2.3 KiB
PHP
83 lines
2.3 KiB
PHP
<?php
|
|
|
|
include('includes/config/config.php');
|
|
include('includes/functions.php');
|
|
include('log_entry.php');
|
|
|
|
error_log("Start Printing Request Attributes");
|
|
$requestStr = "";
|
|
foreach ($_REQUEST as $key => $value) {
|
|
$requestStr .= $key . " : " . $value . "\n";
|
|
|
|
error_log($key . " : " . $value . "<br />\r\n");
|
|
}
|
|
error_log("End Printing Request Attributes");
|
|
|
|
$checkup_type_id = $_REQUEST['checkup_type_id'];
|
|
|
|
$checkup_section_ids = getFieldFromTable('checkup_form_section_ids', 'checkup_type', 'checkup_type_id', $checkup_type_id);
|
|
|
|
error_log("section ids " . $checkup_section_ids);
|
|
|
|
$key_param_name_array = ['systolic blood pressure', 'sbp', 'diastolic blood pressure', 'dbp', 'fbs', 'rbs', 'ppbs', 'height', 'weight', 'total cholesterol'];
|
|
|
|
$data = [];
|
|
|
|
for ($i = 0; $i < count($key_param_name_array); $i++) {
|
|
|
|
$checkup_column_name = "select column_name as name from checkup_parameter where checkup_form_section_id in ($checkup_section_ids) and key_health_map_name=(select key_param_id from key_health_reportable_parameter_master where key_param_name='" . $key_param_name_array[$i] . "' )";
|
|
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);
|
|
|
|
$data[$key_param_name_array[$i]] = $_REQUEST[$row_column_name['name']];
|
|
}
|
|
|
|
$height = $data['height'];
|
|
|
|
$weight = $data['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;
|
|
}
|
|
}
|
|
|
|
$sbp = $data['systolic blood pressure'];
|
|
if (empty($sbp) || $sbp == '') {
|
|
$sbp = $data['sbp'];
|
|
}
|
|
|
|
$dbp = $data['diastolic blood pressure'];
|
|
if (empty($dbp) || $dbp == '') {
|
|
$dbp = $data['dbp'];
|
|
}
|
|
|
|
$sugar = $data['fbs'];
|
|
if (empty($sugar) || $sugar == '') {
|
|
|
|
$sugar = $data['rbs'];
|
|
|
|
if (empty($sugar) || $sugar == '') {
|
|
$sugar = $data['ppbs'];
|
|
}
|
|
}
|
|
|
|
|
|
$cholesterol = $data['total cholesterol'];
|
|
|
|
|
|
$health_score = calculateHealthIndex($sbp, $dbp, $bmi, $sugar, $cholesterol);
|
|
|
|
error_log("entered value to cal health index " . print_r($data, true));
|
|
error_log("calculated health index " . $health_score);
|
|
|
|
echo json_encode($health_score);
|