111 lines
8.4 KiB
PHP
111 lines
8.4 KiB
PHP
<?php
|
|
include('includes/config/config.php');
|
|
include('includes/functions.php');
|
|
include('log_entry.php');
|
|
$noOfRows = $_POST['count_items'];
|
|
error_log("rows: " . $noOfRows);
|
|
$screening_date = $_REQUEST['comm_date'];
|
|
$job_profile = $_REQUEST['jobprofile'];
|
|
error_log("job profile " . $job_profile);
|
|
$canteen_location = $_REQUEST['canteen_location'];
|
|
error_log("screening_date " . $screening_date);
|
|
$patient_id = $_REQUEST['patient_id'];
|
|
$remarks = $_REQUEST['s_remarks'];
|
|
$notes = $_REQUEST['notes'];
|
|
$temp = $_REQUEST['temp'];
|
|
$spo2 = $_REQUEST['spo2'];
|
|
$status = $_REQUEST['attendedStatus'];
|
|
$approval_status = $_REQUEST['approval_status'];
|
|
error_log("status " . $status);
|
|
error_log(" approval_status ".$approval_status);
|
|
$dlf_no = $_REQUEST['dlf_no'];
|
|
$response_id = $_REQUEST['response_id'];
|
|
$ref_no = $_REQUEST['ref'];
|
|
$consern = $_REQUEST['consern'];
|
|
$capa = $_REQUEST['capa'];
|
|
$communication_notes = $_REQUEST['communication_notes'];
|
|
$responsibility = $_REQUEST['responsibility'];
|
|
$completion = $_REQUEST['completion'];
|
|
$status_and_losing = $_REQUEST['status_and_losing'];
|
|
|
|
|
|
$pulse = $_REQUEST['pulse'];
|
|
$distance_vis_rt = $_REQUEST['distance_vis_rt'];
|
|
$distance_vis_lt = $_REQUEST['distance_vis_lt'];
|
|
$near_vis_rt = $_REQUEST['near_vis_rt'];
|
|
$near_vis_lt = $_REQUEST['near_vis_lt'];
|
|
$color_vis = $_REQUEST['color_vis'];
|
|
$id_mark1 = $_REQUEST['id_mark1'];
|
|
$id_mark2 = $_REQUEST['id_mark2'];
|
|
|
|
$height = $_REQUEST['height'];
|
|
$weight = $_REQUEST['weight'];
|
|
$BMI = $_REQUEST['BMI'];
|
|
$bp = $_REQUEST['bp'];
|
|
$rolecode = $_SESSION['RoleCode'];
|
|
begin();
|
|
|
|
if (!empty($response_id)) {
|
|
|
|
if ($rolecode == 'DOC') {
|
|
error_log(" in doc update query");
|
|
$main_query = "update questionaire_master_response set screen_date=STR_TO_DATE('" . $screening_date . "', '%d/%m/%Y %h:%i %p'),remarks='" . $remarks . "',f_status='" . $status . "',notes='" . $notes . "',observation_of_consern='" . $consern . "',approval_status='" . $approval_status . "',temp='" . $temp . "',capa='" . $capa . "',communication_notes='" . $communication_notes . "',responsibility='" . $responsibility . "',completion='" . $completion . "',status_and_losing='" . $status_and_losing . "',spo2='" . $spo2 . "',ref_no='" . $ref_no . "',job_profile='" . $job_profile . "',canteen_location='" . $canteen_location . "',pulse='" . $pulse . "',distance_vis_rt='" . $distance_vis_rt . "',distance_vis_lt='" . $distance_vis_lt . "',near_vis_rt='" . $near_vis_rt . "',near_vis_lt='" . $near_vis_lt . "',color_vis='" . $color_vis . "',id_mark1='" . $id_mark1 . "',id_mark2='" . $id_mark2 . "',approval_user='" . $_SESSION['user_id'] . "',weight='" . $weight . "',height='" . $height . "',BMI='" . $BMI . "',bp='" . $bp . "',modified_by='" . $_SESSION['user_id'] . "' where response_id='" . $response_id . "' ";
|
|
} else {
|
|
if($_REQUEST['forUpdate']!= null){
|
|
$main_query = "update questionaire_master_response set screen_date=STR_TO_DATE('" . $screening_date . "', '%d/%m/%Y %h:%i %p'),remarks='" . $remarks . "',f_status='" . $status . "',notes='" . $notes . "',observation_of_consern='" . $consern . "',approval_status='" . $approval_status . "',temp='" . $temp . "',capa='" . $capa . "',communication_notes='" . $communication_notes . "',responsibility='" . $responsibility . "',completion='" . $completion . "',status_and_losing='" . $status_and_losing . "',spo2='" . $spo2 . "',ref_no='" . $ref_no . "',job_profile='" . $job_profile . "',canteen_location='" . $canteen_location . "',pulse='" . $pulse . "',distance_vis_rt='" . $distance_vis_rt . "',distance_vis_lt='" . $distance_vis_lt . "',near_vis_rt='" . $near_vis_rt . "',near_vis_lt='" . $near_vis_lt . "',color_vis='" . $color_vis . "',id_mark1='" . $id_mark1 . "',id_mark2='" . $id_mark2 . "',approval_user='" . $_SESSION['user_id'] . "',weight='" . $weight . "',height='" . $height . "',BMI='" . $BMI . "',bp='" . $bp . "',modified_by='" . $_SESSION['user_id'] . "' where response_id='" . $response_id . "' ";
|
|
}
|
|
else{
|
|
$new_dlf_no = creatingDLFNo();
|
|
$main_query = "insert into questionaire_master_response set screen_date=STR_TO_DATE('" . $screening_date . "', '%d/%m/%Y %h:%i %p'),patient_id='" . $patient_id . "',f_status='" . $status . "',medical_examination_no='" . $new_dlf_no . "',remarks='" . $remarks . "',approval_status='" . $approval_status . "',notes='" . $notes . "',form_type='" .'dlf' . "',temp='" . $temp . "',spo2='" . $spo2 . "',job_profile='" . $job_profile . "',canteen_location='" . $canteen_location . "',ref_no='" . $ref_no . "',observation_of_consern='" . $consern . "',capa='" . $capa . "',communication_notes='" . $communication_notes . "',responsibility='" . $responsibility . "',completion='" . $completion . "',status_and_losing='" . $status_and_losing . "',pulse='" . $pulse . "',distance_vis_rt='" . $distance_vis_rt . "',distance_vis_lt='" . $distance_vis_lt . "',near_vis_rt='" . $near_vis_rt . "',near_vis_lt='" . $near_vis_lt . "',color_vis='" . $color_vis . "',height='" . $height . "',weight='" . $weight . "',BMI='" . $BMI . "',bp='" . $bp . "',medical_attend='" . $_SESSION['user_id'] . "',id_mark1='" . $id_mark1 . "',id_mark2='" . $id_mark2 . "',modified_by='" . $_SESSION['user_id'] . "',ohc_type_id='" . $_SESSION['current_ohcttype'] . "' ";
|
|
}}
|
|
} else {
|
|
$main_query = "insert into questionaire_master_response set screen_date=STR_TO_DATE('" . $screening_date . "', '%d/%m/%Y %h:%i %p'),patient_id='" . $patient_id . "',f_status='" . $status . "',medical_examination_no='" . $dlf_no . "',remarks='" . $remarks . "',approval_status='" . $approval_status . "',notes='" . $notes . "',form_type='" .'dlf' . "',temp='" . $temp . "',spo2='" . $spo2 . "',job_profile='" . $job_profile . "',canteen_location='" . $canteen_location . "',ref_no='" . $ref_no . "',observation_of_consern='" . $consern . "',capa='" . $capa . "',communication_notes='" . $communication_notes . "',responsibility='" . $responsibility . "',completion='" . $completion . "',status_and_losing='" . $status_and_losing . "',pulse='" . $pulse . "',distance_vis_rt='" . $distance_vis_rt . "',distance_vis_lt='" . $distance_vis_lt . "',near_vis_rt='" . $near_vis_rt . "',near_vis_lt='" . $near_vis_lt . "',color_vis='" . $color_vis . "',height='" . $height . "',weight='" . $weight . "',BMI='" . $BMI . "',bp='" . $bp . "',medical_attend='" . $_SESSION['user_id'] . "',id_mark1='" . $id_mark1 . "',id_mark2='" . $id_mark2 . "',modified_by='" . $_SESSION['user_id'] . "',ohc_type_id='" . $_SESSION['current_ohcttype'] . "' ";
|
|
}
|
|
error_log("main query" . $main_query);
|
|
if (!$result = mysqli_query($conn, $main_query)) {
|
|
error_log("error in main " . mysqli_error($conn));
|
|
rollback();
|
|
} else {
|
|
|
|
if (empty($response_id)) {
|
|
$r_id = mysqli_insert_id($conn);
|
|
} else {
|
|
$r_id = $response_id;
|
|
}
|
|
|
|
for ($i = 0; $i < $noOfRows; $i++) {
|
|
|
|
|
|
$get_query = "select count(*) as total,a.response_id from questionaire_master_response a left join questionaire_master_response_details b on a.response_id = b.response_id where b.question_id='" . ${"question_id$i"} . "' and a.medical_examination_no='" . $dlf_no . "' and a.patient_id='" . $patient_id . "'";
|
|
error_log("query decides the update and delete " . $get_query);
|
|
$result1 = mysqli_query($conn, $get_query);
|
|
$row1 = mysqli_fetch_assoc($result1);
|
|
$count1 = $row1['total'];
|
|
|
|
if ($count1 != 0) {
|
|
error_log('update query');
|
|
$query1 = "update questionaire_master_response_details set question_remarks='" . ${"remarks$i"} . "',question_answer='" . ${"question_ans$i"} . "', modified_by='" . $_SESSION['user_id'] . "' where response_id='" . $r_id . "' and question_id='" . ${"question_id$i"} . "' ";
|
|
} else {
|
|
$query1 = "insert into questionaire_master_response_details set question_id='" . ${"question_id$i"} . "',question_remarks='" . ${"remarks$i"} . "',question_answer='" . ${"question_ans$i"} . "',response_id='" . $r_id . "'";
|
|
}
|
|
error_log("dlf details insert query " . $query1);
|
|
if (!$result = @mysqli_query($conn, $query1)) {
|
|
error_log("dlf details insert query error " . mysqli_error($conn));
|
|
rollback();
|
|
}
|
|
if (mysqli_num_rows($result) > 0) {
|
|
while ($row = @mysqli_fetch_assoc($result)) {
|
|
$data = $row;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
error_log("Data Dlf" . $data);
|
|
|
|
if ($data == null) {
|
|
$data['status'] = 200;
|
|
$data['message'] = "Data not found!";
|
|
}
|
|
commit();
|
|
echo json_encode($data); |