ohctech_p8/auto_populate_vital_for_checkup.php
Dushant Mali 899fb3e65a Upgrade 7 to 8
Upgrade 7 to 8
2024-11-02 18:03:13 +05:30

50 lines
1.7 KiB
PHP

<?php
include('includes/config/config.php');
include('includes/functions.php');
include('log_entry.php');
error_log("Start Printing Request Attributes For Auto Load Height Weight");
$requestStr = "";
foreach ($_REQUEST as $key => $value) {
$requestStr .= $key . " : " . $value . "\n";
error_log($key . " : " . $value . "<br />\r\n");
}
error_log("End Printing Request Attributes");
$emp_id = $_REQUEST['emp_id'];
$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 = ['height', 'weight', 'bmi'];
$data = [];
$response = [];
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]] = $row_column_name['name'];
}
$sql = "select height,weight,bmi from patient_master where id = '" . $emp_id . "'";
error_log("query " . $sql);
$result = mysqli_query($conn, $sql);
$row = mysqli_fetch_assoc($result);
$response[$data['height']] = $row['height'];
$response[$data['weight']] = $row['weight'];
$response[$data['bmi']] = $row['bmi'];
error_log("final vital data " . print_r($response, true));
echo json_encode($response);