csrtechnew.ohctech.in/appointment_history.php
2025-04-14 13:28:09 +05:30

653 lines
17 KiB
PHP

<form id="flex_appointment_form">
<input type="hidden" name="flex_appointment_id" id="flex_appointment_id" />
<input type="hidden" name="appointmentId" id="appointmentId" />
<input type="hidden" name="flex_opd_id" id="flex_opd_id" />
<input type="hidden" name="returnPage" id="returnPage" />
</form>
<div id="flex1" style="display: none"></div>
<form name="export_form" method="post" id="export_form" action="">
<input type="hidden" name="flex_employee_appointment_id" id="flex_employee_appointment_id" /> <input type="hidden" name="pdf_action" id="pdf_action" value="pdf_emp_appointment_list.php" />
<input type="hidden" name="excel_action" id="excel_action" value="excel_emp_appointment_list.php" />
</form>
<script>
function checkQty() {
let appointment = $("#appointment_id").val();
var total_item = $("#count_treatment_item").val();
// alert(total_item);
for (var i = 0; i < total_item; i++) {
var item_id = $("#treatment_item_" + i).val();
var issue_qty = $("#treatment_item_qtygvn_" + i).val();
if (issue_qty == null || issue_qty == '') {
issue_qty = 0;
}
if (item_id == undefined || issue_qty == undefined) continue;
if (issue_qty < 0) {
BootstrapDialog.alert("Negative values are not allowed!!!");
$("#treatment_item_qtygvn_" + i).val("");
return false;
}
var avl_qty = $("#current_stock_" + i).val();
// alert("avl qty "+avl_qty);
if (avl_qty == undefined || avl_qty == '' || avl_qty == null || isNaN(avl_qty)) {
avl_qty = parseInt($("#current_stock_div" + i).text().split(" ")[0]);
if (avl_qty == undefined || avl_qty == '' || avl_qty == null || isNaN(avl_qty)) {
avl_qty = 0;
}
}
// alert("avl qty "+avl_qty);
$.ajax({
type: 'post',
async: false,
url: 'get_prev_issue_qty.php',
data: {
item_id: item_id,
appointment_id: appointment
},
success: function(data) {
let pre_issue = JSON.parse(data);
if (pre_issue == null || pre_issue == '') pre_issue = 0;
if (eval(avl_qty) + eval(pre_issue) < issue_qty) {
// alert(eval(avl_qty)+eval(pre_issue));
BootstrapDialog.alert('Issue quantity can not be greater than available quantity.!!!');
$("#treatment_item_qtygvn_" + i).val("");
return false;
}
},
error: function(data) {
console.log("Something went wrong in fetching the previous itme qty for checking")
}
});
}
}
var flag_empty_ag = 0;
function validate_update(formId, appointment_id) {
checkQty(appointment_id);
let flag_success = 1;
var appointment_date = $('#appointment_date' + appointment_id).val();
if (appointment_date == '') {
BootstrapDialog.alert('Please Enter Appointment Name.!!!');
return false;
}
var complaints = $('#complaints' + appointment_id).val();
if (complaints == '') {
BootstrapDialog.alert('Please Enter Complaints.!!!');
return false;
}
var ailments = $('#ailment_new').val();
if (ailments == '') {
BootstrapDialog.alert('Please Enter Diagnosis.!!!');
return false;
}
if ($("#appointment_type").val() == 'O') {
var ailment_system_new = $('#ailment_system_new').val();
if (ailment_system_new == '' || ailment_system_new == null) {
BootstrapDialog.alert('Please Select Body System.!!!');
return false;
}
}
var total_item = $("#count_treatment_item").val();
for (var i = 0; i < total_item; i++) {
var item_id = $("#treatment_item_" + i).val();
var issue_qty = $("#treatment_item_qtygvn_" + i).val();
var avl_qty = $("#current_stock_" + i).val();
// if (issue_qty > eval(avl_qty)) {
// BootstrapDialog.alert('Issue quantity can not be greater than available quantity.!!!');
// return false;
// }
}
var counter = $("#count_treatment_item").val();
for (var i = 0; i < counter; i++) {
var treatment_qty = $("#treatment_item_total_" + i).val();
var issued_qty = $("#treatment_item_qtygvn_" + i).val();
if (issued_qty == null || issued_qty == '') {
issued_qty = 0;
}
/** if(issued_qty>treatment_qty){
BootstrapDialog.alert(' Issue Qty should be less than or equal to Treatment Qty .!!!');
return false;
}*/
}
<?php if ($_SESSION['RoleCode'] != $__ROLE_DOCTOR) { ?>
for (let i = 0; i < counter; i++) {
let treatment_qty = $("#treatment_item_total_" + i).val();
let issued_qty = $("#treatment_item_qtygvn_" + i).val();
let treatment_item_id = $("#treatment_item_" + i).val();
// alert(issued_qty + " row " + i + " item id " + treatment_item_id);
if (treatment_item_id == undefined || treatment_item_id == '' || issued_qty == undefined) {
continue;
}
if (issued_qty == null || issued_qty == 0 || issued_qty == '') {
if (flag_empty_ag == 0) {
BootstrapDialog.confirm("Issued Qty For Some items is Empty or Zero.Are you ok with it?", function(result) {
if (result) {
flag_empty_ag = 1;
flag_success = 0;
} else {
flag_empty_ag = 0;
flag_success = 0;
}
});
flag_success = 0;
return false;
}
}
}
<?php } ?>
if (flag_success == 1) update_appointment(formId, appointment_id);
}
function update_appointment(formId, appointment_id) {
$.ajax({
url: 'save_opd.php',
type: "POST",
data: $("#" + formId).serialize(),
success: function(data) {
BootstrapDialog.show({
message: 'Details Updated Successfully.',
buttons: [{
label: 'OK',
action: function(dialogItself) {
dialogItself.close();
// window.location.reload();
}
}]
});
<?php if ($_SESSION['RoleCode'] == 'DOC') { ?>
location.href = "home_doctor.php";
<? } else if ($_SESSION['RoleCode'] == 'DIS') { ?>
location.href = "home_pharmacy.php";
<?php } ?>
//window.location.reload();
return;
},
error: function(data) {
BootstrapDialog.alert('Error Updating Details');
return;
}
});
//window.location.reload();
}
function updateTotalMedicineQty(frequency_qty_fieild, treatment_item_days_fieild, treatment_item_total_fieild, treatment_item_total_fieild_div) {
/** frequency_qty = $("#"+frequency_qty_fieild).val();
treatment_item_days=$("#"+treatment_item_days_fieild).val();
if(treatment_item_days==null || treatment_item_days=='' || treatment_item_days==0){
treatment_item_days =1;
}
$("#"+treatment_item_total_fieild).val(treatment_item_days*frequency_qty);
document.getElementById(treatment_item_total_fieild_div+"").innerText =treatment_item_days*frequency_qty;
**/
}
function updatePrice(qty_issued_field, item_id_field, current_rate_field, current_stock_field, price_field) {
/* qty_issued = $("#"+qty_issued_field).val();
item_id = $("#"+item_id_field).val();
current_rate = $("#"+current_rate_field).val();
current_stock = $("#"+current_stock_field).val();
if(parseFloat(current_stock)<parseFloat(qty_issued)){
BootstrapDialog.alert('You trying to issue more than the available qty. Available:'+current_stock+", issued qty:"+qty_issued);
}
price = $("#"+price_field).val(qty_issued*current_rate);
*/
}
function validate(attendedStatus) {
var appointment_date = $('#appointment_date').val();
if (appointment_date == '') {
BootstrapDialog.alert('Please Enter Appointment Name.!!!');
return false;
}
var complaints = $('#complaints').val();
if (complaints == '') {
BootstrapDialog.alert('Please Enter Complaints.!!!');
return false;
}
var counter = $("#count_treatment_item").val();
for (var i = 0; i < counter; i++) {
var treatment_qty = $("#treatment_item_total_" + i).val();
var issued_qty = $("#treatment_item_qtygvn_" + i).val();
if (issued_qty == null || issued_qty == '') {
issued_qty = 0;
}
/* if(issued_qty>treatment_qty){
BootstrapDialog.alert(' Issue Qty should be less than or equal to Treatment Qty .!!!');
return false;
}*/
}
$("#attendedStatus").val(attendedStatus);
save_appointment();
}
function save_appointment() {
var comp = $("#complaints").val();
// alert(comp);
$.ajax({
url: 'save_opd.php',
type: "POST",
data: $("#opd_form").serialize(),
success: function(data) {
BootstrapDialog.show({
message: 'Details Saved Successfully.',
buttons: [{
label: 'OK',
action: function(dialogItself) {
dialogItself.close();
// $("#hide").attr("display","block");
$("#hide").show();
//window.location.reload();
location.href = "home_receptionist.php"
}
}]
});
var data = $.parseJSON(data);
if ($("#appointment_id").val() == "") {
var history_record = $("#history_record").text();
$('#history_record').text(parseInt(history_record) + 1);
}
if (data[0].appointment_id != null) {
$("#appointment_id").val(data[0].appointment_id);
$("#appointment_id_pdf").val(data[0].appointment_id);
}
if (data[1] != null && data[1] != "") {
for (var i = 0; i < data[1].length; i++) {
$("#treatment_id_" + i).val(data[1][i]);
}
}
$('#flex1').flexReload();
},
error: function(data) {
BootstrapDialog.alert('Error Saving Details');
//return;
}
});
}
$(function() {
var w = screen.width * .85;
var roleId = <?php echo $_SESSION['RoleId'] ?>;
var h = 0;
h = (window.innerHeight - ($("#navbar").height() + $(".breadcrumbs").height())) * .65;
$("#flex1").flexigrid({
url: 'specific_emp_appointment_history_script.php?emp_id=<?php echo ($_REQUEST['flex_opd_id'] != '' ? $_REQUEST['flex_opd_id'] : $_REQUEST['flex_patient_id']) ?>',
dataType: 'json',
colModel: [{
display: 'Sr',
name: 'count',
width: w * .02,
sortable: false,
align: 'left'
},
{
display: '',
name: 'link',
width: w * .07,
sortable: false,
align: 'left'
},
{
display: 'Date',
name: 'appointment_date',
width: w * .1,
sortable: true,
align: 'left'
},
{
display: 'Ticket No',
name: 'ticket_no',
width: w * .07,
sortable: true,
align: 'left'
},
{
display: 'ECode/G.Pass',
name: 'emp_code',
width: w * .08,
sortable: true,
align: 'left'
},
{
display: 'Patient Name',
name: 'patient_name',
width: w * .1,
sortable: true,
align: 'left'
},
{
display: 'Emergency',
name: 'IsEmergency',
width: w * .07,
sortable: true,
align: 'left'
},
{
display: 'Injury',
name: 'appointment_type',
width: w * .07,
sortable: true,
align: 'left'
},
{
display: 'Doctor Consulted',
name: 'doctor_attended_flag',
width: w * .07,
sortable: true,
align: 'left'
},
{
display: 'Complaints',
name: 'complaints',
width: w * .1,
sortable: true,
align: 'left'
},
{
display: 'Examination Findings',
name: 'examination_remarks',
width: w * .1,
sortable: true,
align: 'left'
},
{
display: 'Diagnosis',
name: 'injury_types_new',
width: w * .1,
sortable: true,
align: 'left'
},
{
display: 'Treatments',
name: 'hospital_treatment',
width: w * .15,
sortable: true,
align: 'left'
},
{
display: 'Referral',
name: 'referral',
width: w * .05,
sortable: true,
align: 'left'
},
{
display: 'Follow-up',
name: 'followup',
width: w * .05,
sortable: true,
align: 'left'
},
{
display: 'Vitals',
name: 'checkup_results',
width: w * .07,
sortable: false,
align: 'left'
}
],
buttons: [
{
name: 'PDF',
bclass: 'print',
onpress: pdf
},
{
separator: true
},
{
name: 'Excel',
bclass: 'print_excel',
onpress: excel
},
{
separator: true
}
],
searchitems: [
//{display: 'Appointment Id', name : 'appointment_id',isdefault: true},
{
display: 'Employee Code',
name: 'emp_code'
},
{
display: 'Ticket No',
name: 'ticket_no',
isdefault: true
},
{
display: 'Appointment Date (dd/mm/yyyy)',
name: 'appointment_date'
},
{
display: 'Appointment Date Between (dd/mm/yyyy-dd/mm/yyyy)',
name: 'appointment_date_between'
},
{
display: 'Complaints',
name: 'complaints',
},
{
display: 'Examination Findings',
name: 'examination_remarks'
},
{
display: 'Diagnosis',
name: 'ailment_name'
},
{
display: 'Treatments',
name: 'hospital_treatment'
},
{
display: 'Emergency',
name: 'IsEmergency'
},
{
display: 'Injury',
name: 'appointment_type'
},
{
display: 'Remarks',
name: 'remarks'
},
],
sortname: "appointment_date",
sortorder: "desc",
usepager: true, //pagination
//title:"Employee OPD",
useRp: true,
rp: 50, //records per page
showTableToggleBtn: false, //toggle button for the whole table
resizable: true,
// width: w,
height: h,
singleSelect: true
});
});
function pdf1(appointment_id_pdf) {
window.open('opd_form_pdf.php?appointment_id_pdf=' + appointment_id_pdf + '');
}
function pdf2(appointment_id_pdf) {
window.open('injury_form_pdf.php?appointment_id_pdf=' + appointment_id_pdf + '');
}
function pdf(appointment_id) {
window.open('ajax_pdf.php?appointment_id', 'OPD-Injury List');
}
function excel() {
window.open('ajax_excel.php', 'OPD-Injury List');
}
function loadAppointmentHistory(emp_id) {
$.ajax({
url: 'select_appointment_history.php?emp_id=' + emp_id + ' ',
type: 'POST',
success: function(data) {
jQuery(function($) {
$('#id-disable-check').on('click', function() {
var inp = $('#form-input-readonly').get(0);
if (inp.hasAttribute('disabled')) {
inp.setAttribute('readonly', 'true');
inp.removeAttribute('disabled');
inp.value = "This text field is readonly!";
} else {
inp.setAttribute('disabled', 'disabled');
inp.removeAttribute('readonly');
inp.value = "This text field is disabled!";
}
});
$('[data-rel=tooltip]').tooltip({
container: 'body'
});
$('[data-rel=popover]').popover({
container: 'body'
});
autosize($('textarea[class*=autosize]'));
$('textarea.limited').inputlimiter({
remText: '%n character%s remaining...',
limitText: 'max allowed : %n.'
});
//datepicker plugin
//link
$('.date-picker').datepicker({
autoclose: true,
todayHighlight: true
})
//show datepicker when clicking on the icon
.next().on(ace.click_event, function() {
$(this).prev().focus();
});
//or change it into a date range picker
$('.input-daterange').datepicker({
autoclose: true,
format: 'dd/mm/yyyy',
startDate: '1d',
defaultDate: new Date()
});
//to translate the daterange picker, please copy the "examples/daterange-fr.js" contents here before initialization
$('input[name=date-range-picker]').daterangepicker({
'applyClass': 'btn-sm btn-success',
'cancelClass': 'btn-sm btn-default',
locale: {
applyLabel: 'Apply',
cancelLabel: 'Cancel',
}
})
.prev().on(ace.click_event, function() {
$(this).next().focus();
});
});
//end rerun of jquery UI element rendering
//resizeChosen();
//jQuery(window).on('resize', resizeChosen);
},
error: function(data) {
BootstrapDialog.alert('Error Populating Item');
return;
}
});
}
//$( document ).ready(function() {
// loadAppointmentHistory('<?php echo $_REQUEST['flex_patient_id'] ?>');
//});
function expandDetails(id) {
//$("#"+id).closest('tr').next().toggleClass('open');
//$("#"+id).find(ace.vars['.icon']).toggleClass('fa-angle-double-down').toggleClass('fa-angle-double-up');
}
var appointment_id = "";
function open_employee_appointment(appointmentId, appointment_type, emp_id, action) {
if (appointment_type == "O") {
if (action == 'V') {
document.forms['flex_appointment_form'].action = "view_opd.php";
} else if (action == 'E') {
document.forms["flex_appointment_form"].action = "edit_opd.php";
}
} else if (appointment_type == "I") {
if (action == 'V') {
document.forms['flex_appointment_form'].action = "view_injury.php";
} else if (action == 'E') {
document.forms['flex_appointment_form'].action = "edit_injury.php";
}
}
$("#flex_appointment_form").method = "post";
$("#flex_appointment_form").find("#appointmentId").val(appointmentId);
$("#flex_appointment_form").find("#flex_opd_id").val(emp_id);
$("#flex_appointment_form").find("#returnPage").val("appointment_list.php");
$("#flex_appointment_form").submit();
}
</script>