ohctech_p8/get_health_index.php

83 lines
2.3 KiB
PHP
Raw Normal View History

2024-10-16 19:18:52 +05:30
<?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 = [];
2024-11-02 18:03:13 +05:30
for ($i = 0; $i < count($key_param_name_array); $i++) {
2024-10-16 19:18:52 +05:30
$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);