ohctech_p8/pending_medical_examination_list.php
2024-10-16 19:18:52 +05:30

721 lines
16 KiB
PHP

<?php include('techsyn_header.php'); ?>
<!-- Main Content Container for side bar and body-->
<style>
.overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
/* Semi-transparent black background */
z-index: 9999;
/* Set a high z-index to ensure it's displayed on top */
}
</style>
<div class="main-container ace-save-state" id="main-container">
<script type="text/javascript">
try {
ace.settings.loadState('main-container')
} catch (e) {}
</script>
<?php include('techsyn_sidebar.php');
error_reporting(E_ERROR | E_PARSE);
?>
<!--breadcrumb-->
<div class="main-content">
<div class="main-content-inner">
<div class="breadcrumbs ace-save-state" id="breadcrumbs">
<ul class="breadcrumb">
<li>
<i class="ace-icon fa fa-home home-icon"></i>
<a href="#">Home</a>
</li>
<li class="">Patient Visit</li>
<li class="active">Pending Medical Examination</li>
</ul>
</div>
<!-- End of breadcrumb -->
<div class="page-content">
<form name="f1" method="post" action="" id="flex_form_checkup">
<div id="flex1" style="width:100%">
</div>
<input type="hidden" name="flex_checkup_id" id="flex_checkup_id" />
<input type="hidden" name="emp_id_history" id="emp_id_history" />
<input type="hidden" name="checkup_type_id_db" id="checkup_type_id_db" />
<input type="hidden" name="toPage" id="toPage" />
<input type="hidden" name="returnPage" id="returnPage" />
</form>
<form name="flex_medical_form" method="post" action="" id="flex_medical_form">
<input type="hidden" name="medical_exam_id" id="medical_exam_id" />
</form>
<form name="export_form" method="post" id="export_form" action="">
<input type="hidden" name="flex_medical_form" id="flex_medical_form" />
<input type="hidden" name="pdf_action" id="pdf_action" value="pdf_pending_medical_examination.php" />
<input type="hidden" name="excel_action" id="excel_action" value="excel_pending_medical_examination.php" />
</form>
<div id="flex1" style="width:100%">
</div>
</div>
</div><!-- /.page-content -->
</div>
</div><!-- /.main-content -->
<script type="text/javascript">
$(function() {
var w = screen.width * .90;
var h = 0;
h = (window.innerHeight - ($("#navbar").height() + $(".breadcrumbs").height())) * .75;
$("#flex1").flexigrid({
url: 'pending_medical_examination_list_script.php',
dataType: 'json',
colModel: [
// {
// display: 'Select',
// name: 'checkbox',
// width: w * .03,
// sortable: false,
// align: 'left'
// },
{
display: 'Sr',
name: 'count',
width: w * .03,
sortable: false,
align: 'left'
},
{
display: '',
name: '',
width: w * .1,
sortable: false,
align: 'center'
},
{
display: 'Examination Date',
name: 'checkup_date',
width: w * .1,
sortable: true,
align: 'left'
},
{
display: 'Ticket No',
name: 'ticket_no',
width: w * .14,
sortable: true,
align: 'left'
},
{
display: 'Patient Name',
name: 'patient_name',
width: w * .1,
sortable: true,
align: 'left'
},
{
display: 'EMP Code',
name: 'emp_code',
width: w * .1,
sortable: true,
align: 'left'
},
{
display: 'Patient Category',
name: 'patient_cat_id',
width: w * .1,
sortable: true,
align: 'center'
},
{
display: 'Examination Type',
name: 'checkup_type_id',
width: w * .3,
sortable: true,
align: 'left'
},
{
display: 'Additional Tests',
name: 'add_param_ids',
width: w * .12,
sortable: false,
align: 'left'
},
{
display: 'Created By',
name: 'medical_attend',
width: w * .1,
sortable: true,
align: 'left'
},
// {
// display: 'Remarks',
// name: 'remarks',
// width: w * .1,
// sortable: true,
// align: 'left'
// },
// {
// display: 'Test Categories',
// name: 'checkup_section_ids',
// width: w * .3,
// sortable: true,
// align: 'left'
// },
// {
// display: 'Ready for Examation',
// name: 'current_status',
// width: w * .1,
// sortable: true,
// align: 'left'
// },
],
buttons: [
// {
// name: 'PDF',
// bclass: 'print',
// onpress: pdf
// },
// {
// separator: true
// },
{
name: 'Excel',
bclass: 'print_excel',
onpress: excel
},
{
separator: true
},
{
separator: true
},
{
name: 'Download Template',
bclass: 'print_excel',
onpress: download_template
},
{
separator: true
},
{
name: 'Upload Excel',
bclass: 'print_excel',
onpress: upload_excel
},
{
separator: true
},
// {
// name: 'Download Excel',
// bclass: 'print_excel',
// onpress: download_excel
// },
// {
// separator: true
// },
//{
// name: 'Send For Doc Approval',
// bclass: 'print_excel',
// onpress: send_all
//},
{
separator: true
},
{
name: 'Load Lab Data',
bclass: 'add',
onpress: get_lab_data
},
{
separator: true
},
{
name: 'Add Health Surveillance',
bclass: 'add',
onpress: take_to_add_select
}
],
searchitems: [{
display: 'EMP code',
name: 'emp_code',
isdefault: true
},
{
display: 'Patient Name',
name: 'patient_name',
},
{
display: 'Examination Date(DD/MM/YYYY)',
name: 'checkup_date',
isdefault: true
},
{
display: 'Examination Date Range(DD/MM/YYYY)-(DD/MM/YYYY)',
name: 'medical_entry_date_between',
isdefault: true
},
{
display: 'Examination Type',
name: 'checkup_type_id',
isdefault: true
},
{
display: 'Patient Category',
name: 'patient_cat_name'
}
],
sortname: "a.last_modified",
sortorder: "desc",
usepager: true, //pagination
useRp: true,
rp: 50, //records per page
showTableToggleBtn: false, //toggle button for the whole table
resizable: true,
//width: w,
height: h,
singleSelect: true
});
});
function take_to_add_select() {
var form = document.createElement("form");
form.id = "medical_form";
form.method = "POST";
form.action = "add_select_patient.php";
var task = document.createElement("input");
task.type = "hidden";
task.name = "task";
task.value = "direct_medical_entry";
form.appendChild(task);
var is_new_entry = document.createElement("input");
is_new_entry.type = "hidden";
is_new_entry.name = "is_new_entry";
form.appendChild(is_new_entry);
document.body.appendChild(form);
form.submit();
}
function get_lab_data() {
var ComAlert = BootstrapDialog.alert({
message: "Please wait loading the data from Lab Machines..",
closable: false,
});
showOverlay();
$.ajax({
async: 'false',
type: 'POST',
url: 'process_device_result.php',
success: function(data) {
var responseData = JSON.parse(data);
ComAlert.close();
if (responseData.success) {
BootstrapDialog.alert(responseData.message);
} else {
BootstrapDialog.alert(responseData.message);
}
},
error: function(data) {
ComAlert.close();
BootstrapDialog.alert("Something went wrong while loading the data from machine");
}
})
hideOverlay();
}
function showOverlay() {
var overlay = document.createElement('div');
overlay.className = 'overlay';
document.body.appendChild(overlay);
}
function hideOverlay() {
var overlay = document.querySelector('.overlay');
if (overlay) {
overlay.parentNode.removeChild(overlay);
}
}
let checkboxArr = [];
function send_all() {
BootstrapDialog.alert("Please wait auto approving process will take some time do not press anywhere else");
showOverlay();
checkboxArr = [];
document.querySelectorAll('.checkbox').forEach((component) => {
if (component.checked) {
checkboxArr.push(component.getAttribute('value'));
}
});
// console.log(checkboxArr);
if (checkboxArr.length == 0) {
BootstrapDialog.alert("Select some checkboxes to send for doc approval");
} else {
$.ajax({
type: 'post',
url: 'send_doc_approval.php',
data: {
checkupIds: checkboxArr
},
success: function(data) {
if (data == 400) {
BootstrapDialog.alert("Something went wrong while sending for approval");
} else if (data == 200) {
BootstrapDialog.alert("Sent For Doc Approval");
$("#flex1").flexReload();
hideOverlay();
}
},
error: function(data) {
BootstrapDialog.alert("Something went wrong while sending for approval");
hideOverlay();
}
})
}
}
function pdf() {
window.open('ajax_pdf.php', 'OPD-Injury List');
}
function excel() {
console.log("click");
$("#checkup_type_id_m").val("");
$("#checkup_type_id_m").select2();
$("#is_doctor_pending").val('false');
$("#start_date_excel").val("");
$("#end_date_excel").val("");
$('#modal-select-checkup-type-dd-ss').modal("show");
}
function upload_excel() {
window.location = 'upload_excel_medical.php';
}
function download_template() {
$(".save_button").show();
$("#checkup_type_id").val("");
$('#modal-select-checkup-type').modal("show");
}
function download_excel() {
window.location = 'download_excel_medical.php';
}
function add_params(checkup_id, emp_id, checkup_type_id, additional_param_ids) {
// console.log(checkup_id + " " + emp_id + " " + checkup_type_id);
$("#add_emp_id").val(emp_id);
$("#add_checkup_id").val(checkup_id);
$("#add_checkup_type_id").val(checkup_type_id);
$.ajax({
async: 'false',
type: 'post',
url: 'get_parameters.php',
data: {
checkup_type_id: checkup_type_id
},
success: function(data) {
try {
var response = JSON.parse(data);
} catch (err) {
console.log(err);
}
var checkup_parameter_item = "";
response.map((item) => {
// console.log(item);
checkup_parameter_item += "<option value='" + item.checkup_parameter_id + "'>" + item.parameter_name + "</option>"
});
// console.log(checkup_parameter_item);
$("#add_param_name").html(checkup_parameter_item);
$("#add_param_name").trigger('chosen:updated');
$("#modal-parameter").modal("show");
// console.log("already added params " + additional_param_ids);
if (additional_param_ids != null) {
dataarray = additional_param_ids.split(",");
$("#add_param_name").val(dataarray);
$('#add_param_name').trigger('chosen:updated');
}
},
error: function(data) {
BootstrapDialog.alert("Error Loading Parameters Please Try Again");
}
});
}
function delete_checkup(id) {
$("#flex_checkup_id").val(id);
BootstrapDialog.confirm('Are you sure to delete the checkup form?', function(result) {
if (result) {
$.ajax({
url: 'delete_checkup.php',
type: "POST",
data: $("#flex_form_checkup").serialize(),
success: function(data) {
if (data.indexOf("SUCCESS") != -1) {
BootstrapDialog.alert('checkup form Deleted Successfully.');
$("#flex1").flexReload();
} else {
BootstrapDialog.alert('Error Deleting checkup form');
}
return;
},
error: function(data) {
BootstrapDialog.alert('Error Deleting checkup form');
return;
}
});
}
});
}
function open_checkup(checkupId, empId, action, checkup_type_id) {
currentUrl = window.location.href;
//window.location = 'checkup.php?checkup_id='+checkupId+'';
console.log(checkupId + ':' + empId + ' ; ' + action + ' : ' + checkup_type_id);
if (checkupId != null && checkupId != '') {
$("#flex_checkup_id").val(checkupId);
$("#checkup_type_id_db").val(checkup_type_id);
$("#emp_id_history").val(empId);
$("#toPage").val(action);
$("#returnPage").val(currentUrl);
$("#flex_form_checkup").attr('method', 'POST');
$("#flex_form_checkup").attr('action', 'checkup_from_before.php');
$("#flex_form_checkup").submit();
}
}
function get_device_parameters(section_id, appointment_lab_id, followup_lab_id, checkup_id) {
// console.log("get_device_parameters called " + section_id + " " + appointment_lab_id + " " + followup_lab_id + " " + checkup_id);
$.ajax({
type: 'post',
url: 'select_checkup_parameters.php',
data: {
section_id: section_id,
appointment_lab_id: appointment_lab_id,
followup_lab_id: followup_lab_id,
checkup_id: checkup_id,
},
success: function(data) {
try {
var dt = JSON.parse(data);
var checkup_cat = "";
for (var i = 0; i < dt.count; i++) {
checkup_cat += "<option value='" + dt[i].checkup_parameter_id + "' selected>" +
dt[i].device_param_code + "</option>"
$("#device_id").val(dt[i].device_id);
}
$("#param_name").html(checkup_cat);
$("#param_name").trigger('chosen:updated');
} catch (err) {
console.log(err);
}
},
error: function(data) {
BootstrapDialog.alert("Something went wrong while auto selecting the checkup category and parameters");
}
})
}
function generate_barcode(checkup_id, id, checkup_section_ids, appointment_lab_id, followup_lab_id) {
$("#checkup_id").val(checkup_id);
// $("#flex_checkup_type_id").val(checkup_type_id);
$("#appointment_lab_id").val(appointment_lab_id);
$("#followup_lab_id").val(followup_lab_id);
$("#emp_id_barcode").val(id);
$("#emp_id").val(id);
$("#checkup_sections").val(checkup_section_ids);
$("#modal-barcode").modal("show");
let section_arr = [];
$.ajax({
url: 'select_checkup_section_ids.php',
type: 'POST',
data: {
checkup_id: checkup_id
},
dataType: 'json',
success: function(data) {
console.log("sections data " + data);
var checkup_cat = "";
for (var i = 0; i < data.length; i++) {
checkup_cat += "<option selected value='" + data[i].section_id + "'>" + data[i].section_name + "</option>"
section_arr.push(data[i].section_id);
}
$("#checkup_section_id").html(checkup_cat);
$("#param_name").val("");
$("#param_name").trigger('chosen:updated');
// console.log(section_arr);
get_device_parameters(section_arr, appointment_lab_id, followup_lab_id, checkup_id);
},
error: function(data) {
BootstrapDialog.alert('Error');
return;
}
});
}
function open_medical_examination_form(medical_exam_id, patient_id, task) {
if (medical_exam_id != null && medical_exam_id != '' && patient_id != null && patient_id != '') {
$("#medical_exam_id").val(medical_exam_id);
$("#flex_medical_form").attr('method', 'POST');
if (task == 'pme') {
$("#flex_medical_form").attr('action', 'add_patient_physical_parameters_pme.php');
} else if (task == 'ime_short') {
$("#flex_medical_form").attr('action', 'add_patient_physical_parameters_ime_short_term.php');
} else if (task == 'annual') {
$("#flex_medical_form").attr('action', 'add_initial_medical_examination_longterm.php');
} else if (task == 'semi_annual') {
$("#flex_medical_form").attr('action', 'add_patient_physical_parameters_ame_below_40.php');
}
if (task == 'ime_long' || task == 'pre_employment') {
$("#flex_medical_form").attr('action', 'add_patient_physical_parameters.php');
}
$("#flex_medical_form").submit();
}
}
// $(document).ready(function() {
// document.body.getElementsByTagName('th')[0].innerHTML = '<div style="text-align: left; width: 69.552px;"><input type="checkbox" name="selectAll" id="selectAll" onchange></div>'
// let element = document.getElementById("selectAll");
// element.addEventListener('click', (event) => {
// const isChecked = event.target.checked;
// document.querySelectorAll('.checkbox').forEach((component) => {
// component.checked = isChecked;
// });
// });
// });
</script>
<?php include('techsyn_footer.php'); ?>
<?php
include('form/select_checkup_type.php');
?>
<?php
include('select_checkup_type_s.php');
include('form/add_barcode.php');
include('form/add_parameters.php')
?>