1473 lines
78 KiB
PHP
1473 lines
78 KiB
PHP
<?php
|
|
|
|
use Com\Tecnick\Barcode\Type\Square\QrCode\Split;
|
|
|
|
include('includes/config/config.php');
|
|
include('includes/functions.php');
|
|
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_WARNING);
|
|
// include log entry header file
|
|
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");
|
|
save_log($requestStr, 'Save_OPD', 'SAVE', 'save_opd.php');
|
|
// error_reporting(E_ERROR | E_PARSE);
|
|
$followup_id = $_REQUEST['followup_id'];
|
|
|
|
if ($_REQUEST['appointment_id'] == null || $_REQUEST['appointment_id'] == '' || $_REQUEST['appointment_id'] == '0') {
|
|
$appointment_id = $_REQUEST['appoint'];
|
|
} else {
|
|
$appointment_id = $_REQUEST['appointment_id'];
|
|
}
|
|
// echo $appointment_id;
|
|
$data = array();
|
|
$appointment_date = $_POST['appointment_date'];
|
|
$isTreatmentOnly = $_POST['isTreatmentOnly'];
|
|
|
|
error_log('isTreatmentOnly:' . $isTreatmentOnly);
|
|
if ($isTreatmentOnly == 'Y') {
|
|
$sql_update_status_a = " update employee_appointment set attended_status='PHA', clearance_time=STR_TO_DATE('" . $_POST['out_time'] . "', '%d/%m/%Y %h:%i %p'), medi_disbursement='Y' where appointment_id='" . $appointment_id . "'";
|
|
error_log("is treatment only if yes opd query " . $sql_update_status_a);
|
|
if (!$result_update_status_a = @mysqli_query($conn, $sql_update_status_a)) {
|
|
// main insert fails
|
|
|
|
error_log("Exception:" . mysqli_error($conn));
|
|
error_log("Appointment Status Update Failed : " . $sql_update_status_a);
|
|
rollback();
|
|
exit(error_log(mysqli_error($conn)));
|
|
}
|
|
|
|
if($followup_id !='' && $followup_id !=null && $followup_id !=0){
|
|
$sql_update_status = " update followup_details set attended_status='PHA', clearance_time=STR_TO_DATE('" . $_POST['out_time'] . "', '%d/%m/%Y %h:%i %p'), medi_disbursement='Y' where followup_id='" . $followup_id . "' ";
|
|
error_log("is treatment only if yes followup query " . $sql_update_status);
|
|
if (!$result_update_status = @mysqli_query($conn, $sql_update_status)) {
|
|
// main insert fails
|
|
|
|
error_log("Exception:" . mysqli_error($conn));
|
|
error_log("Appointment Status Update Failed : " . $sql_update_status);
|
|
rollback();
|
|
exit(error_log(mysqli_error($conn)));
|
|
}
|
|
goto treatment_section_followup;
|
|
}else{
|
|
|
|
|
|
goto treatment_section;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
$ailment_ids_new = strtoupper($_POST['ailment_new']);
|
|
error_log("ailment_ids_new:" . $ailment_ids_new);
|
|
$patient_id = addslashes($_REQUEST['emp_id']);
|
|
$complaint_ids = strtoupper($_POST['complaints']);
|
|
$finding_ids = strtoupper($_POST['examination_remarks']);
|
|
$referral_ids = ($_POST['referral_point']);
|
|
$referred_by = $_POST['referred_by'];
|
|
$disease_type = $_POST['disease_type'];
|
|
// $ailment_system_ids_new = strtoupper($_POST['ailment_system_new']);
|
|
// $ailment_ids_new = implode ( ',', $_POST ['ailment_new'] );
|
|
$ailment_system_ids_new = implode(',', $_POST['ailment_system_new']);
|
|
$injuryTypes_new = implode(',', $_POST['injury_type_new']);
|
|
$injuryClasses_new = implode(',', $_POST['injury_class_new']);
|
|
|
|
if ($_REQUEST['appointment_type'] == 'O') {
|
|
$injuryParts_new = strtoupper($_POST['injury_part_new']);
|
|
}
|
|
if ($_REQUEST['appointment_type'] == 'I') {
|
|
$injuryParts_new = strtoupper($_POST['injury_part']);
|
|
}
|
|
|
|
$injury_mech = implode(',', $_POST['injury_mech_new']);
|
|
$health_advice_names_new = strtoupper($_POST['health_advice_name_new']);
|
|
$drug_allergy = strtoupper($_POST['drug_allergy']);
|
|
|
|
$tests_new = implode(",",$_POST['recommended_test_new']);
|
|
$test_param_new = implode(",",$_POST['recommended_test_param_new']);
|
|
error_log("selected test param ".$test_param_new);
|
|
|
|
$diagnosis_config = getFieldFromTable('value', 'config', 'key_name', 'diagnosis_tag_switch');
|
|
if (!strcmp(strtolower($diagnosis_config), "true")) {
|
|
$ailment_ids_new = handleDynamicMasterInsertModified("ailment", "ailment_name", "ailment_id", $ailment_ids_new, true);
|
|
error_log("ailment_ids_new:" . implode(',', $ailment_ids_new));
|
|
$ailment_ids_new = getMultiValuedSelectData($ailment_ids_new);
|
|
error_log("ailment_ids_new2:" . $ailment_ids_new);
|
|
}
|
|
if (!strcmp(strtolower($diagnosis_config), "false")) {
|
|
$ailment_ids_new = $_REQUEST['ailment_new'];
|
|
$ailment_ids_new = implode(',', $ailment_ids_new);
|
|
error_log("ailment_ids_new config off : " . print_r($ailment_ids_new, true));
|
|
}
|
|
|
|
$finding_ids = $_REQUEST['examination_remarks'];
|
|
$finding_ids = implode(',', $finding_ids);
|
|
error_log("$finding_ids config off : " . print_r($finding_ids, true));
|
|
|
|
$complaint_config = getFieldFromTable('value', 'config', 'key_name', 'complaint_tag_switch');
|
|
if (!strcmp(strtolower($complaint_config), "true")) {
|
|
$complaint_ids = handleDynamicMasterInsertModified("complaints", "complaint", "complaint_id", $complaint_ids, true);
|
|
error_log("complaint_ids:" . implode(',', $complaint_ids));
|
|
$complaint_ids = getMultiValuedSelectData($complaint_ids);
|
|
error_log("complaint_ids2:" . $complaint_ids);
|
|
}
|
|
if (!strcmp(strtolower($complaint_config), "false")) {
|
|
$complaint_ids = $_REQUEST['complaints'];
|
|
$complaint_ids = implode(',', $complaint_ids);
|
|
error_log("$complaint ids config off : " . print_r($complaint_ids, true));
|
|
}
|
|
|
|
|
|
$drug_allergy = $_REQUEST['drug_allergy'];
|
|
$drug_allergy = implode(',', $drug_allergy);
|
|
error_log("$drug_allergy ids config off : " . print_r($drug_allergy, true));
|
|
|
|
|
|
// $referral_ids = handleDynamicMasterInsert("referral_point", "referral_point_name", "referral_point_id", $referral_ids, true);
|
|
// error_log("referral_ids:" . implode(',', $referral_ids));
|
|
// $referral_ids = getMultiValuedSelectData($referral_ids);
|
|
// error_log("referral_ids2:" . $referral_ids);
|
|
|
|
// handleDynamicMasterInsert("ailment_system","ailment_sys_name","ailment_sys_id",$ailment_system_ids_new);
|
|
/*
|
|
* handleDynamicMasterInsert("injury_type","injury_type_name","injury_type_id",$injuryTypes_new);
|
|
* handleDynamicMasterInsert("injury_class","inj_class_name","inj_class_id",$injuryClasses_new);
|
|
* handleDynamicMasterInsert("injury_part","inj_name","inj_id",$injuryParts_new);
|
|
*/
|
|
// handleDynamicMasterInsert("injury_part","inj_name","inj_id",$injuryParts_new);
|
|
|
|
|
|
handleDynamicMasterInsert("health_advice", "health_advice_name", "health_advice_id", $health_advice_names_new);
|
|
$advise_ids = getCommaSeperatedValuesForInClauseWithSpace("select health_advice_id from health_advice ", "health_advice_name", $health_advice_names_new);
|
|
// handleDynamicMasterInsert("salt_master", "salt_name", "salt_id", $drug_allergy);
|
|
|
|
|
|
error_log('$advise_ids' . $advise_ids);
|
|
|
|
|
|
|
|
|
|
|
|
// handleDynamicMasterInsert("recommended_tests", "test_name", "test_id", $tests_new);
|
|
|
|
// handleDynamicMasterInsert("injury_part", "inj_id", "inj_id", $injuryParts_new);
|
|
|
|
$weight = $_POST['weight'];
|
|
$pulse_output = $_POST['pulse_output'];
|
|
$height = $_POST['height'];
|
|
$spoc2_percent = $_POST['spoc2_percent'];
|
|
$sbp = $_POST['sbp'];
|
|
$dbp = $_POST['dbp'];
|
|
$temperature = $_POST['temperature'];
|
|
$bmi = $_POST['bmi'];
|
|
$respiratory_rate = $_POST['resp_rate'];
|
|
$urine_output = $_POST['urine_output'];
|
|
$avpu = $_POST['avpu'];
|
|
$trama = $_POST['trama'];
|
|
$mobility = $_POST['mobility'];
|
|
$abnormalitys = $_POST['abnormality'];
|
|
|
|
$oxygen_supply = $_POST['oxygen_supply'];
|
|
$glasgow_scale = $_POST['glasgow_coma_scale'];
|
|
$total_cholesterol = $_POST['total_cholesterol'];
|
|
$external_treatments = $_POST['external_treatments'];
|
|
$activity = $_POST['activity'];
|
|
$ppe = $_POST['ppe'];
|
|
$any_medication = $_POST['any_medication'];
|
|
|
|
$injury_remarks = $_POST['injury_remarks'];
|
|
$doc_comment = $_POST['doc_comment'];
|
|
$is_admitted = $_POST['is_admitted'];
|
|
$ambulance_used = $_POST['ambulance_used'];
|
|
$forUpdate = $_POST['forUpdate'];
|
|
$deu_date = $_POST['deu_date'];
|
|
|
|
if ($_REQUEST['ipd'] == 1 || $_REQUEST['ipd'] == '1') {
|
|
if($appointment_id){
|
|
$reporting_time = $_POST['appointment_date'];
|
|
|
|
$detention_master = 'update detention_master set reporting_time=STR_TO_DATE("' . $reporting_time . '","%d/%m/%Y %h:%i %p") ,opd_id="' . $appointment_id . '",modified_by="' . $_SESSION['user_id'] . '" where opd_id = "'. $$appointment_id .'" ';
|
|
error_log('Forward to detention ' . $detention_master);
|
|
if (!$result_detention_master = @mysqli_query($conn, $detention_master)) {
|
|
exit(mysqli_error($conn));
|
|
}
|
|
}
|
|
|
|
$attended_status = 'PHP';
|
|
$isDetention = 'Y';
|
|
} else {
|
|
$attended_status = $_REQUEST['attendedStatus'];
|
|
$isDetention = 'N';
|
|
}
|
|
|
|
|
|
$health_index = calculateHealthIndex($sbp, $dbp, $bmi, $fbs, $total_cholesterol);
|
|
// $ailment_ids = getMultiValuedSelectData(strtoupper($_POST['ailment']));
|
|
// $ailment_system_ids = getMultiValuedSelectData(strtoupper($_POST['ailment_system']));
|
|
// $injuryTypes = getMultiValuedSelectData(strtoupper($_POST['injury_type']));
|
|
// $injuryClasses = getMultiValuedSelectData(strtoupper($_POST['injury_class']));
|
|
// $injuryParts = getMultiValuedSelectData(strtoupper($_POST['injury_part']));
|
|
$health_advice_names = getMultiValuedSelectData(strtoupper($_POST['health_advice_name']));
|
|
$health_risk_names = getMultiValuedSelectData(strtoupper($_POST['health_risk_name']));
|
|
$medicine_disbursement = $_POST['medicine_disbursement'];
|
|
$tests = getMultiValuedSelectData(strtoupper($_POST['recommended_test']));
|
|
|
|
$query = "";
|
|
$query_initial = "";
|
|
$query_mid = "";
|
|
$query_end = " ";
|
|
begin();
|
|
|
|
|
|
$department = getFieldFromTable('dept_id', 'patient_master', 'id', $_REQUEST['emp_id']);
|
|
|
|
|
|
$designation = getFieldFromTable('designation_id', 'patient_master', 'id', $_REQUEST['emp_id']);
|
|
// if this is only for saving treatment information we should skip saving OPD information.
|
|
|
|
if (!empty($appointment_id) && $appointment_id != '' && $appointment_id != null && $appointment_id != ' ') {
|
|
|
|
// error_log($_REQUEST['insert_new']."sumit mali");
|
|
// if($_REQUEST['insert_new']=='insert_new'){
|
|
// $query_initial = "insert into employee_appointment ";
|
|
// $data['message'] = "save";
|
|
|
|
// }else{
|
|
$data['message'] = "update";
|
|
$query_initial = " update employee_appointment ";
|
|
$query_end = " where appointment_id = '" . $appointment_id . "' ";
|
|
|
|
// }
|
|
|
|
|
|
// echo "hhhhhhhhhhhhhh".$query_initial;
|
|
} else {
|
|
|
|
if ($_REQUEST['appointment_type'] == 'O') {
|
|
$ticket_no = creatingTicketNoOPD();
|
|
} else {
|
|
$ticket_no = creatingTicketNoInjury();
|
|
}
|
|
$query_initial = "insert into employee_appointment ";
|
|
$data['message'] = "save";
|
|
|
|
// echo "yyyyyyyyyyyyyyy".$query_initial;
|
|
}
|
|
$rolecode = $_SESSION['RoleCode'];
|
|
|
|
error_log("follow up case or not : " . $_REQUEST['followup_to_opd']);
|
|
|
|
$is_followup = $_REQUEST['followup_to_opd'];
|
|
if ($is_followup == '' || empty($is_followup)) {
|
|
|
|
$followup = date_format(date_create($_POST['followup']),"Y/m/d H:i:s");
|
|
$query = " SET emp_id='" . addslashes($_REQUEST['emp_id']) . "',medi_disbursement='$medicine_disbursement',doctor_attended_flag='$doctor_attended_flag',ticket_no='$ticket_no',remarks_rece='" . $_POST['remarks_rece'] . "',chronic_day='" . $_REQUEST['chronic_day'] . "',doctor_discussed_id='" . $_REQUEST['doctor_discuss_id'] . "',ecg_findings='" . $_POST['ecg_finding'] . "',add_remarks='" . $_POST['add_remarks'] . "',appointment_type='" . addslashes($_REQUEST['appointment_type']) . "',ailment_ids='" . $ailment_ids . "',ailment_system_ids='" . $ailment_system_ids . "',IsEmergency='" . addslashes($_REQUEST['isEmergency']) . "',IsChargeable='" . addslashes($_REQUEST['isChargeable']) . "',
|
|
complaints='" . addslashes($complaint_ids) . "',referred_by = '$referred_by',referred_to='" . $_POST['referred_to'] . "',clinical_opinion = '" . $_POST['clinical_opinion'] . "',
|
|
examination_remarks='" . addslashes($finding_ids) . "',
|
|
bp_sbp ='" . $_REQUEST['sbp'] . "',disease_type = '$disease_type',injury_area_cat='" . $_POST['injury_area_cat'] . "',injury_area_type = '" . $_POST['injury_area_type'] . "',
|
|
heart_rate='" . $_POST['heart_rate'] . "',height='$height',pulse_output='$pulse_output',weight='$weight',
|
|
bp_dbp ='" . $_REQUEST['dbp'] . "',ipd ='" . $_REQUEST['ipd'] . "',
|
|
blood_sugar_fbs ='" . $_REQUEST['fbs'] . "',blood_sugar_rbs ='" . $_REQUEST['rbs'] . "',
|
|
blood_sugar_ppbs ='" . $_REQUEST['ppbs'] . "',
|
|
referral ='" . ($referral_ids) . "',
|
|
followup ='$followup',case_type='" . $_POST['case_type'] . "',health_status='".$_POST['health_status']."',observation_note='".$_POST['observation_note']."',shift_type='" . $_POST['shift_type'] . "',injury_def='" . $_POST['injury_def'] . "',
|
|
remarks ='$remarks',activity='$activity',ppe='$ppe',any_medication='$any_medication',
|
|
drug_allergy='" . addslashes($drug_allergy) . "',injury_remarks = '$injury_remarks',doc_comment='$doc_comment',is_admitted='$is_admitted',discharge_time=STR_TO_DATE('" . $_POST['discharge_time'] . "', '%d/%m/%Y %h:%i %p'),referral_doc='" . $_POST['referral_doc'] . "',report_time=STR_TO_DATE('" . $_POST['report_time'] . "', '%d/%m/%Y %h:%i %p'),ambulance_used='$ambulance_used',safety_officer = '" . $_POST['safety_officer'] . "',
|
|
deu_date ='" . $deu_date . "',
|
|
appointment_date =STR_TO_DATE('" . $_POST['appointment_date'] . "', '%d/%m/%Y %h:%i %p'),
|
|
clearance_time =STR_TO_DATE('" . $_POST['out_time'] . "', '%d/%m/%Y %h:%i %p'),
|
|
injury_time =STR_TO_DATE('" . $_POST['injury_time'] . "', '%d/%m/%Y %h:%i %p'),
|
|
rest_from_time =STR_TO_DATE('" . $_POST['rest_from_time'] . "', '%d/%m/%Y %h:%i %p'),
|
|
rest_to_time =STR_TO_DATE('" . $_POST['rest_to_time'] . "', '%d/%m/%Y %h:%i %p'),injury_mech='$injury_mech',
|
|
modified_by='" . $_SESSION['user_id'] . "' ,ohc_type_id='" . $_SESSION['current_ohcttype'] . "',
|
|
injury_types='" . $injuryTypes . "', injury_classes='" . $injuryClasses . "',
|
|
injury_parts='" . $injuryParts . "', injury_form='" . $_REQUEST['injury_form'] . "', absence_start=STR_TO_DATE('" . $_POST['absence_start'] . "', '%d/%m/%Y'),
|
|
absence_end=STR_TO_DATE('" . $_POST['absence_end'] . "', '%d/%m/%Y'), injury_firm='" . $_REQUEST['injury_firm'] . "',incident_location='" . addslashes($_REQUEST['incident_location']) . "',
|
|
injury_sbu='" . $_REQUEST['injury_sbu'] . "', injury_section='" . $_REQUEST['injury_section'] . "',doctor_discussed='" . $_REQUEST['doctor_discussed'] . "', doctor_last_attended='" . $_REQUEST['doctor_last_attended'] . "',
|
|
injury_sub_section='" . $_REQUEST['injury_sub_section'] . "',tests='" . $tests . "',injury_procedure= '" . addslashes($_REQUEST['pro_remarks']) . "',
|
|
hospital_treatment='" . $_REQUEST['hospital_treatment'] . "' ,health_advices='" . $health_advice_names . "' ,
|
|
total_amount='" . $_POST['order_level_total'] . "', abnormalitys='" . implode(",", $abnormalitys) . "', token_no='" . addslashes($_REQUEST['token_no']) . "',
|
|
ailments_new='" . addslashes($ailment_ids_new) . "',ailment_systems_new='" . addslashes($ailment_system_ids_new) . "',
|
|
injury_types_new='" . addslashes($injuryTypes_new) . "',injury_classes_new='" . addslashes($injuryClasses_new) . "',
|
|
injury_parts_new='" . addslashes($injuryParts_new) . "',recommended_tests_new='" . addslashes($tests_new) . "',recommended_test_param_new='".addslashes($test_param_new)."',bmi='" . addslashes($bmi) . "',respiratory_rate = '" . addslashes($respiratory_rate) . "',
|
|
urine_output = '" . addslashes($urine_output) . "',avpu = '" . addslashes($avpu) . "',trama='" . addslashes($trama) . "',mobility='" . addslashes($mobility) . "',oxygen_supply='" . addslashes($oxygen_supply) . "',glasgow_coma_scale='" . addslashes($glasgow_coma_scale) . "',total_cholesterol = '" . addslashes($total_cholesterol) . "',health_index = '" . addslashes($health_index) . "',
|
|
temperature='" . addslashes($temperature) . "',spo2_percent='" . addslashes($spoc2_percent) . "',
|
|
external_treatments='" . addslashes($external_treatments) . "',attended_status='" . addslashes($attended_status) . "',is_detention = '" . addslashes($isDetention) . "',branch_area='" . $_POST['branch_area'] . "',dept='" . $_POST['dept'] . "',injury_cause='" . $_POST['injury_cause'] . "',
|
|
followup_to_opd='" . addslashes($_REQUEST['followup_to_opd']) . "', pre_med_history= '" . addslashes($_REQUEST['pre_med_history']) . "' ,followup_remarks='" . addslashes($_REQUEST['followup_remarks']) . "',
|
|
health_advices_new='" . addslashes($health_advice_names_new) . "',department='" . $department . "',designation='" . $designation . "'";
|
|
|
|
$query = $query_initial . " " . $query . " " . $query_end;
|
|
|
|
error_log("Appointment Save: " . $query);
|
|
} else {
|
|
|
|
|
|
|
|
|
|
|
|
$in_q = '';
|
|
$end_q = '';
|
|
|
|
if ($followup_id == '' || $followup_id == null) {
|
|
$in_q = "insert into followup_details";
|
|
} else {
|
|
$in_q = "update followup_details";
|
|
$end_q = "where followup_id='" . $followup_id . "'";
|
|
}
|
|
$followup_query = $in_q . " SET appointment_id='" . addslashes($_REQUEST['followup_to_opd']) . "', emp_id='" . addslashes($_REQUEST['emp_id']) . "',medi_disbursement='$medicine_disbursement',chronic_day='" . $_REQUEST['chronic_day'] . "',doctor_discussed_id='" . $_REQUEST['doctor_discuss_id'] . "',doctor_attended_flag='$doctor_attended_flag',ticket_no='$ticket_no',remarks_rece='" . $_POST['remarks_rece'] . "',ecg_findings='" . $_POST['ecg_finding'] . "',add_remarks='" . $_POST['add_remarks'] . "',appointment_type='" . addslashes($_REQUEST['appointment_type']) . "',ailment_ids='" . $ailment_ids . "',ailment_system_ids='" . $ailment_system_ids . "',IsEmergency='" . addslashes($_REQUEST['isEmergency']) . "',IsChargeable='" . addslashes($_REQUEST['isChargeable']) . "',
|
|
complaints='" . addslashes($complaint_ids) . "',referred_by = '$referred_by',referred_to='" . $_POST['referred_to'] . "',clinical_opinion = '" . $_POST['clinical_opinion'] . "',
|
|
examination_remarks='" . addslashes($finding_ids) . "',
|
|
bp_sbp ='" . $_REQUEST['sbp'] . "',disease_type = '$disease_type',pre_med_history= '" . addslashes($_REQUEST['pre_med_history']) . "',injury_area_cat='" . $_POST['injury_area_cat'] . "',injury_area_type = '" . $_POST['injury_area_type'] . "',
|
|
heart_rate='" . $_POST['heart_rate'] . "',height='$height',weight='$weight',
|
|
bp_dbp ='" . $_REQUEST['dbp'] . "',ipd ='" . $_REQUEST['ipd'] . "',
|
|
blood_sugar_fbs ='" . $_REQUEST['fbs'] . "',blood_sugar_rbs ='" . $_REQUEST['rbs'] . "',
|
|
blood_sugar_ppbs ='" . $_REQUEST['ppbs'] . "',
|
|
referral ='" . ($referral_ids) . "',
|
|
followup =STR_TO_DATE('" . $_POST['followup'] . "','%Y-%m-%d'),case_type='" . $_POST['case_type'] . "',shift_type='" . $_POST['shift_type'] . "',injury_def='" . $_POST['injury_def'] . "',
|
|
remarks ='$remarks',activity='$activity',ppe='$ppe',any_medication='$any_medication',
|
|
drug_allergy='" . addslashes($drug_allergy) . "',injury_remarks = '$injury_remarks',doc_comment='$doc_comment',is_admitted='$is_admitted',discharge_time=STR_TO_DATE('" . $_POST['discharge_time'] . "', '%d/%m/%Y %h:%i %p'),referral_doc='" . $_POST['referral_doc'] . "',report_time=STR_TO_DATE('" . $_POST['report_time'] . "', '%d/%m/%Y %h:%i %p'),ambulance_used='$ambulance_used',safety_officer = '" . $_POST['safety_officer'] . "',
|
|
deu_date ='" . $deu_date . "',
|
|
appointment_date =STR_TO_DATE('" . $_POST['appointment_date'] . "', '%d/%m/%Y %h:%i %p'),
|
|
clearance_time =STR_TO_DATE('" . $_POST['out_time'] . "', '%d/%m/%Y %h:%i %p'),
|
|
injury_time =STR_TO_DATE('" . $_POST['injury_time'] . "', '%d/%m/%Y %h:%i %p'),
|
|
rest_from_time =STR_TO_DATE('" . $_POST['rest_from_time'] . "', '%d/%m/%Y %h:%i %p'),
|
|
rest_to_time =STR_TO_DATE('" . $_POST['rest_to_time'] . "', '%d/%m/%Y %h:%i %p'),injury_mech='$injury_mech',
|
|
modified_by='" . $_SESSION['user_id'] . "' ,ohc_type_id='" . $_SESSION['current_ohcttype'] . "',
|
|
injury_types='" . $injuryTypes . "', injury_classes='" . $injuryClasses . "',
|
|
injury_parts='" . $injuryParts . "', injury_form='" . $_REQUEST['injury_form'] . "', absence_start=STR_TO_DATE('" . $_POST['absence_start'] . "', '%d/%m/%Y'),
|
|
absence_end=STR_TO_DATE('" . $_POST['absence_end'] . "', '%d/%m/%Y'), injury_firm='" . $_REQUEST['injury_firm'] . "',incident_location='" . addslashes($_REQUEST['incident_location']) . "',
|
|
injury_sbu='" . $_REQUEST['injury_sbu'] . "', injury_section='" . $_REQUEST['injury_section'] . "',doctor_discussed='" . $_REQUEST['doctor_discussed'] . "', doctor_last_attended='" . $_REQUEST['doctor_last_attended'] . "',
|
|
injury_sub_section='" . $_REQUEST['injury_sub_section'] . "',tests='" . $tests . "',injury_procedure= '" . addslashes($_REQUEST['pro_remarks']) . "',
|
|
hospital_treatment='" . $_REQUEST['hospital_treatment'] . "' ,health_advices='" . $health_advice_names . "' ,
|
|
total_amount='" . $_POST['order_level_total'] . "', abnormalitys='" . implode(",", $abnormalitys) . "', token_no='" . addslashes($_REQUEST['token_no']) . "',
|
|
ailments_new='" . addslashes($ailment_ids_new) . "',ailment_systems_new='" . addslashes($ailment_system_ids_new) . "',
|
|
injury_types_new='" . addslashes($injuryTypes_new) . "',injury_classes_new='" . addslashes($injuryClasses_new) . "',
|
|
injury_parts_new='" . addslashes($injuryParts_new) . "',recommended_tests_new='" . addslashes($tests_new) . "',recommended_test_param_new='".addslashes($test_param_new)."',bmi='" . addslashes($bmi) . "',respiratory_rate = '" . addslashes($respiratory_rate) . "',
|
|
urine_output = '" . addslashes($urine_output) . "',avpu = '" . addslashes($avpu) . "',trama='" . addslashes($trama) . "',mobility='" . addslashes($mobility) . "',oxygen_supply='" . addslashes($oxygen_supply) . "',glasgow_coma_scale='" . addslashes($glasgow_coma_scale) . "',total_cholesterol = '" . addslashes($total_cholesterol) . "',health_index = '" . addslashes($health_index) . "',
|
|
temperature='" . addslashes($temperature) . "',spo2_percent='" . addslashes($spoc2_percent) . "',
|
|
external_treatments='" . addslashes($external_treatments) . "',attended_status='" . addslashes($attended_status) . "',is_detention = '" . addslashes($isDetention) . "',branch_area='" . $_POST['branch_area'] . "',dept='" . $_POST['dept'] . "',injury_cause='" . $_POST['injury_cause'] . "',
|
|
followup_to_opd='" . addslashes($_REQUEST['followup_to_opd']) . "', followup_remarks='" . addslashes($_REQUEST['followup_remarks']) . "',
|
|
health_advices_new='" . addslashes($health_advice_names_new) . "',department='" . $department . "',designation='" . $designation . "'" . $end_q;
|
|
}
|
|
|
|
|
|
|
|
error_log("FOLLOWUP QUERY:" . $followup_query);
|
|
|
|
if (isset($is_followup) && !empty($is_followup)) {
|
|
$appointment_id = addslashes($_REQUEST['followup_to_opd']);
|
|
|
|
if (!$result_followup = mysqli_query($conn, $followup_query)) {
|
|
rollback();
|
|
error_log("Exception:" . mysqli_error($conn));
|
|
error_log("Followup Save: " . $followup_query);
|
|
exit(error_log(mysqli_error($conn)));
|
|
} else {
|
|
|
|
if (empty($followup_id)) {
|
|
$query = "select max(followup_id) followup_id from followup_details where emp_id = '" . addslashes($_REQUEST['emp_id']) . "' ";
|
|
// echo $query;
|
|
error_log("max followup_id_id query: " . $query);
|
|
if (!$result = @mysqli_query($conn, $query)) {
|
|
rollback();
|
|
exit(error_log(mysqli_error($conn)));
|
|
}
|
|
if (mysqli_num_rows($result) > 0) {
|
|
while ($row = mysqli_fetch_assoc($result)) {
|
|
$followup_id = $row['followup_id'];
|
|
}
|
|
}
|
|
}
|
|
error_log("FOLLOWUP ID::" . $followup_id);
|
|
|
|
error_log("---------FOLLOW-UP SECTION STARTS EXECUTING-------------");
|
|
|
|
// insert dynamic vitals start in case of follow-up
|
|
|
|
$app_update = "update employee_appointment set followup_to_opd='" . addslashes($_REQUEST['followup_to_opd']) . "',attended_status='" . addslashes($attended_status) . "' where appointment_id='" . addslashes($_REQUEST['followup_to_opd']) . "'";
|
|
error_log($app_update);
|
|
if (!$result_app_update = mysqli_query($conn, $app_update)) {
|
|
error_log("error while saving followup entry in save opd " . mysqli_error($conn) . " query is " . $app_update);
|
|
}
|
|
|
|
// $exists_or_not = "select * from employee_appointment_vitals where appointment_id='" . $appointment_id . "' and followup_id = '" . $followup_id . "'";
|
|
// $exist_result = mysqli_query($conn, $exists_or_not);
|
|
// $exists_or_not_rows = mysqli_num_rows($exist_result);
|
|
// if ($exists_or_not_rows > 0) {
|
|
// $delete_old = "delete from employee_appointment_vitals where appointment_id='" . $appointment_id . "' and followup_id = '" . $followup_id . "'";
|
|
|
|
// if (!$res_del = mysqli_query($conn, $delete_old)) {
|
|
// rollback();
|
|
// error_log("error in employee_appointment_vitals deleting " . mysqli_error($conn) . " query " . $delete_old);
|
|
// }
|
|
// }
|
|
|
|
// $param_query = "";
|
|
|
|
// if ($_REQUEST['appointment_type'] == 'O') {
|
|
// $param_query = "select * from checkup_parameter a left join
|
|
// key_health_reportable_parameter_master b on a.key_health_map_name=b.key_param_id where opd_param='1' and enabled='Y' order by column_order";
|
|
// } else if ($_REQUEST['appointment_type'] == 'I') {
|
|
// $param_query = "select * from checkup_parameter a left join
|
|
// key_health_reportable_parameter_master b on a.key_health_map_name=b.key_param_id where inj_param='1' and enabled='Y' order by column_order";
|
|
// }
|
|
|
|
// error_log("dynamic param query " . $param_query);
|
|
// $result_param = mysqli_query($conn, $param_query);
|
|
// while ($row_param = mysqli_fetch_assoc($result_param)) {
|
|
// $color = "color_" . $row_param['column_name'];
|
|
// $dynamic_param_save = "insert into employee_appointment_vitals set appointment_id='" . $appointment_id . "',followup_id='" . $followup_id . "',param_key='" . $row_param['column_name'] . "',param_value='" . $_REQUEST[$row_param['column_name']] . "',color='" . $_REQUEST[$color] . "'";
|
|
|
|
// error_log("EMPLOYEE VITALS QUERY::" . $dynamic_param_save);
|
|
|
|
// if (!$result_dynamic = mysqli_query($conn, $dynamic_param_save)) {
|
|
// error_log("dynamic param save query " . mysqli_error($conn) . " " . $dynamic_param_save);
|
|
// rollback();
|
|
// }
|
|
|
|
// if ($row_param['key_param_name'] == 'height') {
|
|
// $patient_sql = "update patient_master set height = '" . $_REQUEST[$row_param['column_name']] . "' where id='" . $_REQUEST['emp_id'] . "'";
|
|
// error_log("patient update sql " . $patient_sql);
|
|
// if (!@mysqli_query($conn, $patient_sql)) {
|
|
// rollback();
|
|
// error_log("Exception:" . mysqli_error($conn));
|
|
// exit(error_log(mysqli_error($conn)));
|
|
// }
|
|
// }
|
|
|
|
// if ($row_param['key_param_name'] == 'weight') {
|
|
// $patient_sql = "update patient_master set weight = '" . $_REQUEST[$row_param['column_name']] . "' where id='" . $_REQUEST['emp_id'] . "'";
|
|
// error_log("patient update sql " . $patient_sql);
|
|
// if (!@mysqli_query($conn, $patient_sql)) {
|
|
// rollback();
|
|
// error_log("Exception:" . mysqli_error($conn));
|
|
// exit(error_log(mysqli_error($conn)));
|
|
// }
|
|
// }
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
// for examination notes start
|
|
// $count_notes = $_POST['count_notes'];
|
|
// error_log("notes count " . $count_notes);
|
|
|
|
// $exists_or_not = "select * from employee_examination_notes where appointment_id='" . $appointment_id . "' and followup_id = '" . $followup_id . "'";
|
|
// $exist_result = mysqli_query($conn, $exists_or_not);
|
|
// $exists_or_not_rows = mysqli_num_rows($exist_result);
|
|
// if ($exists_or_not_rows > 0) {
|
|
// $delete_notes_old = "delete from employee_examination_notes where appointment_id='" . $appointment_id . "' and followup_id = '" . $followup_id . "'";
|
|
// if (!$res_del = mysqli_query($conn, $delete_notes_old)) {
|
|
// rollback();
|
|
// error_log("error in notes deleting " . mysqli_error($conn) . " query " . $delete_notes_old);
|
|
// }
|
|
// }
|
|
|
|
// entry in notes table
|
|
// for ($i = 0; $i < $count_notes; $i++) {
|
|
// if (${"ailment_system_note$i"} != null || ${"ailment_system_note$i"} != '') {
|
|
|
|
// $ailment_system = implode(",", ${"ailment_system_note$i"});
|
|
|
|
// $insert_notes = "insert into employee_examination_notes set appointment_id = '" . $appointment_id . "',followup_id='" . $followup_id . "',ailment_system= '" . $ailment_system . "',notes='" . ${"examination_note$i"} . "' ";
|
|
// error_log("notes insert query " . $insert_notes);
|
|
|
|
// if (!$result_notes = mysqli_query($conn, $insert_notes)) {
|
|
// error_log("notes insert failed " . mysqli_error($conn));
|
|
// rollback();
|
|
// }
|
|
// }
|
|
// }
|
|
|
|
//end
|
|
|
|
|
|
|
|
// $diagnosis_count = $_POST['count_items'];
|
|
// error_log("diagnosis count " . $diagnosis_count);
|
|
|
|
// $exists_or_not = "select * from diagnosis_detail where appointment_id='" . $appointment_id . "' and followup_id = '" . $followup_id . "'";
|
|
// $exist_result = mysqli_query($conn, $exists_or_not);
|
|
// $exists_or_not_rows = mysqli_num_rows($exist_result);
|
|
// if ($exists_or_not_rows > 0) {
|
|
// $delete_diagnosis_old = "delete from diagnosis_detail where appointment_id='" . $appointment_id . "' and followup_id = '" . $followup_id . "'";
|
|
|
|
|
|
// if (!$res_del = mysqli_query($conn, $delete_diagnosis_old)) {
|
|
// rollback();
|
|
// error_log("error in diagnosis deleting " . mysqli_error($conn) . " query " . $delete_diagnosis_old);
|
|
// }
|
|
// }
|
|
|
|
// entry in diagnosis detail table
|
|
// for ($i = 0; $i < $diagnosis_count; $i++) {
|
|
// if (${"ailment_system_new$i"} != null || ${"ailment_system_new$i"} != '') {
|
|
// if ($i == 0) {
|
|
// $insert_diagnosis = "insert into diagnosis_detail set appointment_id = '" . $appointment_id . "',followup_id='" . $followup_id . "',ailment_system_id= '" . ${"ailment_system_new$i"} . "',ailment_id='" . ${"ailment_new$i"} . "',body_part= '" . ${"injury_part$i"} . "',injury_classification='" . ${"injury_class_new$i"} . "',injury_type='" . ${"injury_type_new$i"} . "',injury_mechanism='" . ${"injury_mech_new$i"} . "',industrial_type='" . ${"industrial_type$i"} . "',work_type='" . ${"work_type$i"} . "',fresh_old_injury='" . ${"fresh_old_injury$i"} . "',injury_description='" . ${"injury_description$i"} . "',first_aid='" . ${"first_aid$i"} . "',is_primary='Y',associated_hazard='" . ${"hazard$i"} . "' ";
|
|
// error_log("diagnosis insert query " . $insert_diagnosis);
|
|
|
|
// if (!$result_diagnosis = mysqli_query($conn, $insert_diagnosis)) {
|
|
// error_log("diagnosis insert failed " . mysqli_error($conn));
|
|
// rollback();
|
|
// }
|
|
// } else {
|
|
// $insert_diagnosis = "insert into diagnosis_detail set appointment_id = '" . $appointment_id . "',followup_id='" . $followup_id . "',ailment_system_id= '" . ${"ailment_system_new$i"} . "',ailment_id='" . ${"ailment_new$i"} . "',body_part= '" . ${"injury_part$i"} . "',injury_classification='" . ${"injury_class_new$i"} . "',injury_type='" . ${"injury_type_new$i"} . "',injury_mechanism='" . ${"injury_mech_new$i"} . "',industrial_type='" . ${"industrial_type$i"} . "',work_type='" . ${"work_type$i"} . "',fresh_old_injury='" . ${"fresh_old_injury$i"} . "',injury_description='" . ${"injury_description$i"} . "',first_aid='" . ${"first_aid$i"} . "',is_primary='N',associated_hazard='" . ${"hazard$i"} . "' ";
|
|
// error_log("diagnosis insert query " . $insert_diagnosis);
|
|
|
|
// if (!$result_diagnosis = mysqli_query($conn, $insert_diagnosis)) {
|
|
// error_log("diagnosis insert failed " . mysqli_error($conn));
|
|
// rollback();
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
if (!empty($advise_ids)) {
|
|
updatePatientHealthInfo($patient_id, 'ADC', $advise_ids, $appointment_date, '', 0);
|
|
}
|
|
|
|
if (!empty($drug_allergy)) {
|
|
updatePatientHealthInfo($patient_id, 'ALG', $drug_allergy, $appointment_date, '', 0);
|
|
}
|
|
|
|
error_log('abbb ' . $abnormalitys);
|
|
error_log('abbb ' . implode(",", $abnormalitys));
|
|
if (!empty(implode(",", $abnormalitys))) {
|
|
updatePatientAbnormalityInfo($patient_id, implode(",", $abnormalitys), $appointment_date);
|
|
}
|
|
|
|
if (!empty($injuryTypes_new)) {
|
|
updatePatientHealthInfo($patient_id, 'INJ', $injuryTypes_new, $appointment_date, '', 0);
|
|
}
|
|
|
|
|
|
|
|
if (empty($followup_id)) {
|
|
$query = "select max(followup_id) followup_id from followup_details where appointment_id = '" . $appointment_id . "' ";
|
|
// echo $query;
|
|
error_log("max followup_id query: " . $query);
|
|
if (!$result = @mysqli_query($conn, $query)) {
|
|
rollback();
|
|
exit(error_log(mysqli_error($conn)));
|
|
}
|
|
if (mysqli_num_rows($result) > 0) {
|
|
while ($row = mysqli_fetch_assoc($result)) {
|
|
$followup_id = $row['followup_id'];
|
|
}
|
|
}
|
|
}
|
|
|
|
// if this is only for saving treatment information we should skip saving OPD information.
|
|
treatment_section_followup:
|
|
error_log("at treatment section");
|
|
|
|
// lab test saving logic for followup start
|
|
if ($rolecode == 'DOC' && $_POST['recommended_test_new'] != '' && $_POST['recommended_test_new'] != null) {
|
|
|
|
|
|
|
|
$exists_lab_sql = "select * from checkup_form where appointment_id='" . $appointment_id . "' and followup_id='".$followup_id."'";
|
|
$result_lab_sql = mysqli_query($conn, $exists_lab_sql);
|
|
$num_rows_lab = mysqli_num_rows($result_lab_sql);
|
|
$row_lab_sql = mysqli_fetch_assoc($result_lab_sql);
|
|
|
|
$lab_init_query = "";
|
|
$lab_end_query = "";
|
|
$lab_checkup_ticket_no = "";
|
|
if ($num_rows_lab > 0) {
|
|
$lab_checkup_ticket_no = $row_lab_sql['ticket_no'];
|
|
$lab_init_query = "update checkup_form set ";
|
|
$lab_end_query = " where appointment_id= '" . $appointment_id . "' and checkup_id='" . $row_lab_sql['checkup_id'] . "' and followup_id='".$followup_id."'";
|
|
} else {
|
|
$lab_checkup_ticket_no = creatingCheckupTicketNo();
|
|
$lab_init_query = "insert into checkup_form set appointment_id='" . $appointment_id . "', followup_id='".$followup_id."', ";
|
|
$lab_end_query = "";
|
|
}
|
|
|
|
error_log("tests " . $tests_new);
|
|
|
|
$userEntriesArray = explode(",", $tests_new);
|
|
$userEntriesArray = array_map('trim', $userEntriesArray);
|
|
|
|
error_log("user entries array" . $userEntriesArray);
|
|
|
|
// getting checkup lab test master id
|
|
// $checkup_type_id_sql = "select checkup_type_id from checkup_type where checkup_form_section_ids in (select section_id from checkup_form_section where section_name in ('" . join("','", $userEntriesArray) . "'))";
|
|
$checkup_type_id_sql = "select checkup_type_id from checkup_type where checkup_type_code='LAB_TEST'";
|
|
if ($result_checkup = mysqli_query($conn, $checkup_type_id_sql)) {
|
|
error_log("error in getting checkup type id " . mysqli_error($conn) . " query is " . $checkup_type_id_sql);
|
|
}
|
|
$row_checkup = mysqli_fetch_assoc($result_checkup);
|
|
$checkup_type_id = $row_checkup['checkup_type_id'];
|
|
|
|
error_log("checkup type id " . $checkup_type_id);
|
|
// getting checkup lab test master id end -- ----
|
|
|
|
// getting checkup lab section ids
|
|
/*$sql_existing_entries_test = "SELECT group_concat(section_id) as test_id from checkup_form_section where section_name in('" . join("','", $userEntriesArray) . "')";
|
|
|
|
error_log("existing entries query in MRP status:" . $sql_existing_entries_test);
|
|
|
|
if (!$result_existing_entries_test = @mysqli_query($conn, $sql_existing_entries_test)) {
|
|
error_log("error retrieving:" . mysqli_error($conn) . " sql_existing_entries_test:" . $sql_existing_entries);
|
|
}
|
|
$row_test = mysqli_fetch_assoc($result_existing_entries_test);
|
|
$test_section_ids = $row_test['test_id']; */
|
|
// getting checkup lab section id end -----
|
|
$SESSION_emp_id = getTableFieldValue("doctors_master", "doctor_id", "doctor_emp_id", getTableFieldValue("tbl_users", "emp_id", "user_id", $_SESSION["user_id"]));
|
|
// inserting for lab record
|
|
$lab_entry = $lab_init_query . " checkup_date=STR_TO_DATE('" . $appointment_date . "','%d/%m/%Y %h:%i %p') , ticket_no='" . $lab_checkup_ticket_no . "' , emp_id='" . $_REQUEST['emp_id'] . "' , checkup_type_id='" . $checkup_type_id . "' ,referred_by='" . $SESSION_emp_id . "', checkup_section_ids='" . $tests_new . "' , current_status='MRP' , ohc_type_id='" . $_SESSION['current_ohcttype'] . "' , modified_by='" . $_SESSION['user_id'] . "' " . $lab_end_query;
|
|
|
|
error_log("saving lab entry in save opd " . $lab_entry);
|
|
|
|
if (!$result_lab = mysqli_query($conn, $lab_entry)) {
|
|
error_log("error while saving lab entry in save opd " . mysqli_error($conn) . " query is " . $lab_entry);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//lab test saving logic for followup end
|
|
/* for reset Item Stock At Dispensary Level */
|
|
|
|
if ($_SESSION["RoleCode"] == 'DIS') {
|
|
resetItemStockAtDispensaryLevelForFollowup($appointment_id, $_SESSION['current_ohcttype'], 0);
|
|
} else {
|
|
resetItemStockAtStoreLevelForFollowup($appointment_id, $_SESSION['current_ohcttype'], 0);
|
|
}
|
|
|
|
/* delete all child table during update records */
|
|
if (!@mysqli_query($conn, "delete from appointment_stock_history where appointment_id='" . $appointment_id . "' and followup_id = '" . $followup_id . "'")) {
|
|
|
|
error_log("Exception:" . mysqli_error($conn));
|
|
exit(error_log(mysqli_error($conn)));
|
|
rollback();
|
|
}
|
|
if (!@mysqli_query($conn, "delete from treatment where appointment_id='" . $appointment_id . "' and followup_id = '" . $followup_id . "' ")) {
|
|
error_log('del_t '."delete from treatment where appointment_id='" . $appointment_id . "' and followup_id = '" . $followup_id . "'");
|
|
error_log("Exception:" . mysqli_error($conn));
|
|
exit(error_log(mysqli_error($conn)));
|
|
rollback();
|
|
}
|
|
|
|
if ($isTreatmentOnly != 'Y' && !@mysqli_query($conn, "delete from treatment_external where appointment_id='" . $appointment_id . "' and followup_id = '" . $followup_id . "'")) {
|
|
|
|
error_log("Exception:" . mysqli_error($conn));
|
|
exit(error_log(mysqli_error($conn)));
|
|
rollback();
|
|
}
|
|
|
|
/* insert all child table during save or update records */
|
|
|
|
error_log("treatment row count:" . $_REQUEST['count_treatment_item']);
|
|
for ($i = 0; $i <= $_REQUEST['count_treatment_item']; $i++) {
|
|
|
|
error_log("treatment_item:" . $i . ":" . ${"treatment_item$i"});
|
|
|
|
if (${"treatment_item$i"} != null && ${"treatment_item$i"} != "") {
|
|
// To Check Item is Dressing Or Not
|
|
// echo "adarsh";
|
|
$is_dressing_item = toCheckDressingItem(${"treatment_item$i"});
|
|
error_log("is_dressing_item:" . $is_dressing_item);
|
|
|
|
if ($is_dressing_item == 'P') {
|
|
|
|
// echo ${"group_child_flag_$i"};
|
|
if (${"group_child_flag_$i"} == '1') {
|
|
//When found form elements for the group items.. select udpated values from form.
|
|
|
|
$result_for_group_items = getGroupItems(${"treatment_item$i"});
|
|
$no_rows_group_child = mysqli_num_rows($result_for_group_items);
|
|
error_log("no_rows_group_child:" . $no_rows_group_child);
|
|
for ($j = 0; $j < $no_rows_group_child; $j++) {
|
|
$treatment_given_by = '';
|
|
|
|
if (addslashes($_POST['child_item_qty_gvn' . $i . '_' . $j]) != 0 || addslashes($_POST['chihld_item_qty_gvn' . $i . '_' . $j]) != '' || addslashes($_POST['child_item_qty_gvn' . $i . '_' . $j]) != null) {
|
|
$treatment_given_by = ",issue_by='" . $_SESSION['user_id'] . "'";
|
|
}
|
|
|
|
error_log("Child Item:" . $_POST['child_item_' . $i . '_' . $j]);
|
|
$group_item_id = getFieldFromTable('group_id', 'group_items', 'item_id', $_POST['child_item_' . $i . '_' . $j]);
|
|
error_log("group_item_id:" . $group_item_id);
|
|
error_log("childitem:" . $_POST['child_item_' . $i . '_' . $j]);
|
|
$query_treatment = "insert into treatment set appointment_id='" . $appointment_id . "',is_display='N',group_item_id='" . $group_item_id . "', followup_id = '" . $followup_id . "',
|
|
item_id='" . addslashes($_POST['child_item_' . $i . '_' . $j]) . "',item_qty='" . addslashes($_POST['child_item_qty_gvn' . $i . '_' . $j]) . "',
|
|
issued_qty='" . addslashes($_POST['child_item_qty_gvn' . $i . '_' . $j]) . "', modified_by='" . $_SESSION['user_id'] . "'" . $treatment_given_by;
|
|
|
|
error_log("query_treatment: " . $query_treatment);
|
|
if (!$result = @mysqli_query($conn, $query_treatment)) {
|
|
|
|
error_log("Exception:" . mysqli_error($conn));
|
|
error_log("Failed query_treatment: " . $query_treatment);
|
|
rollback();
|
|
exit(error_log(mysqli_error($conn)));
|
|
}
|
|
// echo $query_treatment;
|
|
$query_stock_history = " insert into appointment_stock_history set appointment_id='" . $appointment_id . "', followup_id = '" . $followup_id . "',
|
|
item_qty='" . addslashes($_POST['child_item_qty_gvn' . $i . '_' . $j]) . "', item_id='" . addslashes($_POST['child_item_' . $i . '_' . $j]) . "',
|
|
issued_qty='" . addslashes($_POST['child_item_qty_gvn' . $i . '_' . $j]) . "'" . $treatment_given_by;
|
|
error_log("query_stock_history: " . $query_stock_history);
|
|
if (!@mysqli_query($conn, $query_stock_history)) {
|
|
rollback();
|
|
error_log("issues while updating appointment_stock_history: " . $query_stock_history);
|
|
error_log("Exception:" . mysqli_error($conn));
|
|
exit(mysqli_error($conn));
|
|
}
|
|
// to update Dispensary Items
|
|
if ($_SESSION("RoleCode") == 'DIS') {
|
|
resetItemStockAtDispensaryLevelForGroupItems(-$_POST['child_item_qty_gvn' . $i . '_' . $j], $_POST['child_item_' . $i . '_' . $j], $_SESSION['current_ohcttype']);
|
|
} else {
|
|
resetItemStockAtStoreLevelForGroupItems(-$_POST['child_item_qty_gvn' . $i . '_' . $j], $_POST['child_item_' . $i . '_' . $j], $_SESSION['current_ohcttype'], $_POST['item_batch_no' . $i]);
|
|
}
|
|
}
|
|
} else {
|
|
//When nothing is returned from the form for the group items.. we use the calculated item qty from dressing item definitions
|
|
|
|
|
|
|
|
$result_for_group_items = getGroupItems(${"treatment_item$i"});
|
|
while ($row_for_group_items = mysqli_fetch_array($result_for_group_items)) {
|
|
|
|
$treatment_qty_given_by = '';
|
|
|
|
if ($doctor_attended_flag == 'Y' && (($_SESSION['RoleCode'] == 'DIS') || in_array('DIS', explode(',', $_SESSION['RoleCode'])))) {
|
|
if (addslashes($row_for_group_items['qty']) == 0 || addslashes($row_for_group_items['qty']) == '' || addslashes($row_for_group_items['qty']) == null) {
|
|
$treatment_qty_given_by = ",issue_by='" . $_SESSION['user_id'] . "'";
|
|
error_log('trtr');
|
|
}
|
|
}
|
|
$query_treatment = "insert into treatment set appointment_id='" . $appointment_id . "',is_display='N',group_item_id='" . $row_for_group_items['group_id'] . "',
|
|
item_id='" . addslashes($row_for_group_items['item_id']) . "',item_qty='" . addslashes($row_for_group_items['qty']) . "',followup_id = '" . $followup_id . "',
|
|
issued_qty='" . addslashes($row_for_group_items['qty']) . "', modified_by='" . $_SESSION['user_id'] . "'" . $treatment_qty_given_by;
|
|
|
|
if (!@mysqli_query($conn, $query_treatment)) {
|
|
error_log("issues while updating treatment: " . $query_treatment);
|
|
error_log("Exception:" . mysqli_error($conn));
|
|
rollback();
|
|
exit(mysqli_error($conn));
|
|
}
|
|
// echo $query_treatment;
|
|
$query_stock_history = " insert into appointment_stock_history set appointment_id='" . $appointment_id . "',
|
|
item_qty='" . addslashes($row_for_group_items['qty']) . "', item_id='" . addslashes($row_for_group_items['item_id']) . "',followup_id = '" . $followup_id . "',
|
|
issued_qty='" . addslashes($row_for_group_items['qty']) . "'" . $treatment_qty_given_by;
|
|
if (!@mysqli_query($conn, $query_stock_history)) {
|
|
rollback();
|
|
error_log("Appointment stock history saving error::" . mysqli_error($conn) . "Failed query::" . $query_stock_history);
|
|
exit(mysqli_error($conn));
|
|
}
|
|
}
|
|
}
|
|
} //end for handling of dressing items
|
|
$treatment_qty_given_by = '';
|
|
|
|
|
|
|
|
if ($doctor_attended_flag == 'Y' && (($_SESSION['RoleCode'] == 'DIS') || in_array('DIS', explode(',', $_SESSION['RoleCode'])))) {
|
|
if (addslashes(${"treatment_item_qtygvn$i"}) != 0 || addslashes(${"treatment_item_qtygvn$i"}) != '' || addslashes(${"treatment_item_qtygvn$i"}) != null) {
|
|
$treatment_qty_given_by = ",issue_by='" . $_SESSION['user_id'] . "'";
|
|
|
|
error_log('trtr');
|
|
}
|
|
}
|
|
|
|
$query_treatment = "insert into treatment SET appointment_id='" . $appointment_id . "',
|
|
item_id='" . addslashes(${"treatment_item$i"}) . "',item_qty='" . addslashes(${"dose_qty$i"}) . "',followup_id = '" . $followup_id . "',
|
|
issued_qty='" . addslashes(${"treatment_item_qtygvn$i"}) . "', item_batch_no='" . addslashes(${"item_batch_no$i"}) . "',dosage='" . addslashes(${"dosage$i"}) . "',
|
|
for_days='" . addslashes(${"treatment_item_days$i"}) . "', frequency_id='" . ${"treatment_item_dosage$i"} . "', timing_id = '" . ${"timings$i"} . "',
|
|
dosage_category_id='" . ${"treatment_item_dosage_category$i"} . "', modified_by='" . $_SESSION['user_id'] . "'" . $treatment_qty_given_by;
|
|
error_log("query_treatment: " . $query_treatment);
|
|
if (!$result = @mysqli_query($conn, $query_treatment)) {
|
|
|
|
error_log("Error Saving Treatment data: " . mysqli_error($conn) . " Failed Query:" . $query_treatment);
|
|
rollback();
|
|
exit(mysqli_error($conn));
|
|
}
|
|
|
|
// insert or update the cost details start
|
|
if ($is_dressing_item != 'P') {
|
|
$past_appointment_id = getTableFieldValue('treatment_cost_master', 'appointment_id', 'item_id', ${"treatment_item$i"}, 'appointment_id', $appointment_id);
|
|
|
|
if ($past_appointment_id != "" || $past_appointment_id != null) {
|
|
error_log("update case for cost saving");
|
|
$initquery = "update ";
|
|
$endquery = " where item_id='" . ${"treatment_item$i"} . "' and appointment_id='" . $appointment_id . "'";
|
|
} else {
|
|
$initquery = "insert into ";
|
|
$endquery = "";
|
|
}
|
|
|
|
$present_per_unit_cost = getTableFieldValue('item_cost', 'item_rate_latest', 'ohc_type_id', $_SESSION['current_ohcttype'], 'item_id', ${"treatment_item$i"});
|
|
|
|
$total_cost = round($present_per_unit_cost * ${"treatment_item_qtygvn$i"});
|
|
|
|
error_log("latest rate for item id " . getItemWithFormName(${"treatment_item$i"}) . " " . $present_per_unit_cost . " total sum for this item " . $total_cost);
|
|
|
|
$insert_treatment_cost = $initquery . " treatment_cost_master set appointment_id='" . $appointment_id . "',ohc_type_id='" . $_SESSION['current_ohcttype'] . "',issued_item_cost='" . $total_cost . "',item_id='" . ${"treatment_item$i"} . "' $endquery";
|
|
|
|
error_log("cost saving query for opd " . $insert_treatment_cost);
|
|
|
|
if (!$insert_treatment_cost_result = mysqli_query($conn, $insert_treatment_cost)) {
|
|
error_log("error in cost saving query for opd " . mysqli_error($conn));
|
|
}
|
|
} else {
|
|
|
|
$past_appointment_id = getTableFieldValue('treatment_cost_master', 'appointment_id', 'item_id', ${"treatment_item$i"}, 'appointment_id', $appointment_id);
|
|
|
|
if ($past_appointment_id != "" || $past_appointment_id != null) {
|
|
error_log("update case for cost saving");
|
|
$initquery = "update ";
|
|
$endquery = " where item_id='" . ${"treatment_item$i"} . "' and appointment_id='" . $appointment_id . "'";
|
|
} else {
|
|
$initquery = "insert into ";
|
|
$endquery = "";
|
|
}
|
|
|
|
$present_per_unit_cost = getTableFieldValue('group_items', 'cost', 'group_id', ${"treatment_item$i"});
|
|
|
|
$total_cost = round($present_per_unit_cost * ${"treatment_item_qtygvn$i"});
|
|
|
|
error_log("latest rate for item id " . getItemWithFormName(${"treatment_item$i"}) . " " . $present_per_unit_cost . " total sum for this item " . $total_cost);
|
|
|
|
$insert_treatment_cost = $initquery . " treatment_cost_master set appointment_id='" . $appointment_id . "',ohc_type_id='" . $_SESSION['current_ohcttype'] . "',issued_item_cost='" . $total_cost . "',item_id='" . ${"treatment_item$i"} . "' $endquery";
|
|
|
|
error_log("cost saving query for opd " . $insert_treatment_cost);
|
|
|
|
if (!$insert_treatment_cost_result = mysqli_query($conn, $insert_treatment_cost)) {
|
|
error_log("error in cost saving query for opd " . mysqli_error($conn));
|
|
}
|
|
}
|
|
// insert or update the cost details end
|
|
$treatment_qty_given_by = '';
|
|
|
|
|
|
if ($doctor_attended_flag == 'Y' && (($_SESSION['RoleCode'] == 'DIS') || in_array('DIS', explode(',', $_SESSION['RoleCode'])))) {
|
|
if (addslashes(${"treatment_item_qtygvn$i"}) != 0 || addslashes(${"treatment_item_qtygvn$i"}) != '' || addslashes(${"treatment_item_qtygvn$i"}) != null) {
|
|
$treatment_qty_given_by = ",issue_by='" . $_SESSION['user_id'] . "'";
|
|
error_log('trtr');
|
|
}
|
|
}
|
|
$query_stock_history = " insert into appointment_stock_history set appointment_id='" . $appointment_id . "', current_stock='" . addslashes(${"current_stock$i"}) . "',item_qty='" . addslashes(${"frequency_qty$i"}) . "', item_id='" . addslashes(${"treatment_item$i"}) . "',issued_qty='" . addslashes(${"treatment_item_qtygvn$i"}) . "' ,followup_id = '" . $followup_id . "'" . $treatment_qty_given_by;
|
|
error_log(" appointment_stock_history update details: " . $query_stock_history);
|
|
if (!@mysqli_query($conn, $query_stock_history)) {
|
|
rollback();
|
|
error_log("Error updating appointment_stock_history: " . $query_stock_history);
|
|
error_log("Exception:" . mysqli_error($conn));
|
|
exit(error_log(mysqli_error($conn)));
|
|
}
|
|
|
|
if (${"group_child_flag_$i"} != '1')
|
|
updaterItemStock($_SESSION['current_ohcttype'], addslashes(${"treatment_item$i"}), ${"treatment_item_qtygvn$i"}, ${"item_batch_no$i"});
|
|
|
|
|
|
|
|
/*
|
|
* //$item_batch_no=getMinExpiaryDateItem($_SESSION['current_ohcttype'], addslashes(${"treatment_item$i"}));
|
|
* $current_stock_qty=getStockQtyAtDispensaryLevel(${"treatment_item$i"},$_SESSION['current_ohcttype']);
|
|
* // echo $current_stock_qty;
|
|
* $stock_qty = floatval ( $current_stock_qty ) - (floatval ( ${"treatment_item_qtygvn$i"} ));
|
|
* //echo $stock_qty;
|
|
* $current_stock_query = "update item_stock_dispensary set stock_qty='".$stock_qty."' where item_id='".${"treatment_item$i"}."' and item_batch_no='".$item_batch_no."' and ohc_location_id='".$_SESSION['current_ohcttype']."' ";
|
|
* // echo $current_stock_query;
|
|
* mysqli_query($conn,$current_stock_query );
|
|
*/
|
|
} else if ($isTreatmentOnly != 'Y' && ${"treatment_item_external$i"} != null && ${"treatment_item_external$i"} != "") {
|
|
|
|
$query_treatment = "insert into treatment_external SET appointment_id='" . $appointment_id . "',followup_id = '" . $followup_id . "',
|
|
item_name='" . addslashes(${"treatment_item_external$i"}) . "',item_qty='" . addslashes(${"dose_qty$i"}) . "',timing = '" . addslashes(${"timings$i"}) . "',dosage='" . addslashes(${"treatment_item_dosage$i"}) . "',
|
|
for_days='" . addslashes(${"treatment_item_days$i"}) . "', dosage_category_id='" . ${"treatment_item_dosage_category$i"} . "', modified_by='" . $_SESSION['user_id'] . "' ";
|
|
|
|
if (!@mysqli_query($conn, $query_treatment)) {
|
|
|
|
error_log("error saving treamemnt external : " . $query_treatment);
|
|
error_log("Exception:" . mysqli_error($conn));
|
|
|
|
exit(error_log(mysqli_error($conn)));
|
|
rollback();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($is_followup == ''||$is_followup == 0 || empty($is_followup )) {
|
|
|
|
if (!$result = @mysqli_query($conn, $query)) {
|
|
error_log("APPOINTMENT QUERY FAILING");
|
|
// main insert fails
|
|
rollback();
|
|
error_log("Exception:" . mysqli_error($conn));
|
|
error_log("Appointment Save: " . $query);
|
|
exit(error_log(mysqli_error($conn)));
|
|
} else {
|
|
|
|
if ($_REQUEST['ipd'] == 1 || $_REQUEST['ipd'] == '1') {
|
|
if($appointment_id == '' || $appointment_id == NULL){
|
|
$reporting_time = $_POST['appointment_date'];
|
|
$last_id = $conn->insert_id;
|
|
|
|
$detention_master = 'insert into detention_master set reporting_time=STR_TO_DATE("' . $reporting_time . '","%d/%m/%Y %h:%i %p") ,opd_id="' . $last_id . '",modified_by="' . $_SESSION['user_id'] . '" ';
|
|
error_log('Forward to detention ' . $detention_master);
|
|
if (!$result_detention_master = @mysqli_query($conn, $detention_master)) {
|
|
exit(mysqli_error($conn));
|
|
}
|
|
}
|
|
}
|
|
// if (empty($appointment_id)) {
|
|
// //mysqli_insert_id($conn);
|
|
// $appointment_id = getTableFieldValue('employee_appointment','max(appointment_id)','','')+1;
|
|
// }
|
|
|
|
|
|
// check if its insert or update case for diagnosis
|
|
|
|
// // insert dynamic vitals start
|
|
|
|
// $exists_or_not = "select * from employee_appointment_vitals where appointment_id='" . $appointment_id . "' and followup_id='0'";
|
|
// $exist_result = mysqli_query($conn, $exists_or_not);
|
|
// $exists_or_not_rows = mysqli_num_rows($exist_result);
|
|
// if ($exists_or_not_rows > 0) {
|
|
// $delete_old = "delete from employee_appointment_vitals where appointment_id='" . $appointment_id . "' and followup_id='0'";
|
|
|
|
// if (!$res_del = mysqli_query($conn, $delete_old)) {
|
|
// rollback();
|
|
// error_log("error in employee_appointment_vitals deleting " . mysqli_error($conn) . " query " . $delete_old);
|
|
// }
|
|
// }
|
|
|
|
|
|
// $param_query = "";
|
|
|
|
// if ($_REQUEST['appointment_type'] == 'O') {
|
|
// $param_query = "select * from checkup_parameter a left join
|
|
// key_health_reportable_parameter_master b on a.key_health_map_name=b.key_param_id where opd_param='1' and enabled='Y' order by column_order";
|
|
// } else if ($_REQUEST['appointment_type'] == 'I') {
|
|
// $param_query = "select * from checkup_parameter a left join
|
|
// key_health_reportable_parameter_master b on a.key_health_map_name=b.key_param_id where inj_param='1' and enabled='Y' order by column_order";
|
|
// }
|
|
|
|
// error_log("dynamic param query " . $param_query);
|
|
// $result_param = mysqli_query($conn, $param_query);
|
|
// while ($row_param = mysqli_fetch_assoc($result_param)) {
|
|
// $color = "color_" . $row_param['column_name'];
|
|
// $dynamic_param_save = "insert into employee_appointment_vitals set appointment_id='" . $appointment_id . "',param_key='" . $row_param['column_name'] . "',param_value='" . $_REQUEST[$row_param['column_name']] . "',color='" . $_REQUEST[$color] . "'";
|
|
|
|
// error_log("dynamic param save query " .$dynamic_param_save);
|
|
|
|
// if (!$result_dynamic = mysqli_query($conn, $dynamic_param_save)) {
|
|
// error_log("dynamic param save query " . mysqli_error($conn) . " " . $dynamic_param_save);
|
|
// rollback();
|
|
// }
|
|
|
|
// if ($row_param['key_param_name'] == 'height') {
|
|
// $patient_sql = "update patient_master set height = '" . $_REQUEST[$row_param['column_name']] . "' where id='" . $_REQUEST['emp_id'] . "'";
|
|
// error_log("patient update sql " . $patient_sql);
|
|
// if (!@mysqli_query($conn, $patient_sql)) {
|
|
// rollback();
|
|
// error_log("Exception:" . mysqli_error($conn));
|
|
// exit(error_log(mysqli_error($conn)));
|
|
// }
|
|
// }
|
|
|
|
// if ($row_param['key_param_name'] == 'weight') {
|
|
// $patient_sql = "update patient_master set weight = '" . $_REQUEST[$row_param['column_name']] . "' where id='" . $_REQUEST['emp_id'] . "'";
|
|
// error_log("patient update sql " . $patient_sql);
|
|
// if (!@mysqli_query($conn, $patient_sql)) {
|
|
// rollback();
|
|
// error_log("Exception:" . mysqli_error($conn));
|
|
// exit(error_log(mysqli_error($conn)));
|
|
// }
|
|
// }
|
|
// }
|
|
//end
|
|
|
|
|
|
|
|
|
|
// for examination notes start
|
|
// / $count_notes = $_POST['count_notes'];
|
|
// error_log("notes count " . $count_notes);
|
|
|
|
// $exists_or_not = "select * from employee_examination_notes where appointment_id='" . $appointment_id . "' and followup_id = '0'";
|
|
// $exist_result = mysqli_query($conn, $exists_or_not);
|
|
// $exists_or_not_rows = mysqli_num_rows($exist_result);
|
|
// if ($exists_or_not_rows > 0) {
|
|
// $delete_notes_old = "delete from employee_examination_notes where appointment_id='" . $appointment_id . "' and followup_id = '0'";
|
|
// if (!$res_del = mysqli_query($conn, $delete_notes_old)) {
|
|
// rollback();
|
|
// error_log("error in notes deleting " . mysqli_error($conn) . " query " . $delete_notes_old);
|
|
// }
|
|
// }
|
|
|
|
// entry in notes table
|
|
// for ($i = 0; $i < $count_notes; $i++) {
|
|
// if (${"ailment_system_note$i"} != null || ${"ailment_system_note$i"} != '') {
|
|
|
|
// $ailment_system = implode(",", ${"ailment_system_note$i"});
|
|
|
|
// $insert_notes = "insert into employee_examination_notes set appointment_id = '" . $appointment_id . "',ailment_system= '" . $ailment_system . "',notes='" . ${"examination_note$i"} . "' ";
|
|
// error_log("notes insert query " . $insert_notes);
|
|
|
|
// if (!$result_notes = mysqli_query($conn, $insert_notes)) {
|
|
// error_log("notes insert failed " . mysqli_error($conn));
|
|
// rollback();
|
|
// }
|
|
// }
|
|
// }
|
|
|
|
//end
|
|
|
|
|
|
// $diagnosis_count = $_POST['count_items'];
|
|
// error_log("diagnosis count " . $diagnosis_count);
|
|
|
|
// $exists_or_not = "select * from diagnosis_detail where appointment_id='" . $appointment_id . "' and followup_id='0'";
|
|
// $exist_result = mysqli_query($conn, $exists_or_not);
|
|
// $exists_or_not_rows = mysqli_num_rows($exist_result);
|
|
// if ($exists_or_not_rows > 0) {
|
|
// $delete_diagnosis_old = "delete from diagnosis_detail where appointment_id='" . $appointment_id . "' and followup_id='0'";
|
|
|
|
// if (!$res_del = mysqli_query($conn, $delete_diagnosis_old)) {
|
|
// rollback();
|
|
// error_log("error in diagnosis deleting " . mysqli_error($conn) . " query " . $delete_diagnosis_old);
|
|
// }
|
|
// }
|
|
|
|
// entry in diagnosis detail table
|
|
// for ($i = 0; $i < $diagnosis_count; $i++) {
|
|
// if (${"ailment_system_new$i"} != null || ${"ailment_system_new$i"} != '') {
|
|
// if ($i == 0) {
|
|
// $insert_diagnosis = "insert into diagnosis_detail set appointment_id = '" . $appointment_id . "',ailment_system_id= '" . ${"ailment_system_new$i"} . "',ailment_id='" . ${"ailment_new$i"} . "',body_part= '" . ${"injury_part$i"} . "',injury_classification='" . ${"injury_class_new$i"} . "',injury_type='" . ${"injury_type_new$i"} . "',injury_mechanism='" . ${"injury_mech_new$i"} . "',industrial_type='" . ${"industrial_type$i"} . "',work_type='" . ${"work_type$i"} . "',fresh_old_injury='" . ${"fresh_old_injury$i"} . "',injury_description='" . ${"injury_description$i"} . "',first_aid='" . ${"first_aid$i"} . "',is_primary='Y',associated_hazard='" . ${"hazard$i"} . "' ";
|
|
// error_log("diagnosis insert query " . $insert_diagnosis);
|
|
|
|
// if (!$result_diagnosis = mysqli_query($conn, $insert_diagnosis)) {
|
|
// error_log("diagnosis insert failed " . mysqli_error($conn));
|
|
// rollback();
|
|
// }
|
|
// } else {
|
|
// $insert_diagnosis = "insert into diagnosis_detail set appointment_id = '" . $appointment_id . "',ailment_system_id= '" . ${"ailment_system_new$i"} . "',ailment_id='" . ${"ailment_new$i"} . "',body_part= '" . ${"injury_part$i"} . "',injury_classification='" . ${"injury_class_new$i"} . "',injury_type='" . ${"injury_type_new$i"} . "',injury_mechanism='" . ${"injury_mech_new$i"} . "',industrial_type='" . ${"industrial_type$i"} . "',work_type='" . ${"work_type$i"} . "',fresh_old_injury='" . ${"fresh_old_injury$i"} . "',injury_description='" . ${"injury_description$i"} . "',first_aid='" . ${"first_aid$i"} . "',is_primary='N',associated_hazard='" . ${"hazard$i"} . "' ";
|
|
// error_log("diagnosis insert query " . $insert_diagnosis);
|
|
|
|
// if (!$result_diagnosis = mysqli_query($conn, $insert_diagnosis)) {
|
|
// error_log("diagnosis insert failed " . mysqli_error($conn));
|
|
// rollback();
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
|
|
//training
|
|
if (!empty($advise_ids)) {
|
|
updatePatientHealthInfo($patient_id, 'ADC', $advise_ids, $appointment_date, '', 0);
|
|
}
|
|
|
|
if (!empty($drug_allergy)) {
|
|
updatePatientHealthInfo($patient_id, 'ALG', $drug_allergy, $appointment_date, '', 0);
|
|
}
|
|
|
|
error_log('abbb ' . $abnormalitys);
|
|
error_log('abbb ' . implode(",", $abnormalitys));
|
|
if (!empty(implode(",", $abnormalitys))) {
|
|
updatePatientAbnormalityInfo($patient_id, implode(",", $abnormalitys), $appointment_date);
|
|
}
|
|
|
|
if (!empty($injuryTypes_new)) {
|
|
updatePatientHealthInfo($patient_id, 'INJ', $injuryTypes_new, $appointment_date, '', 0);
|
|
}
|
|
|
|
|
|
|
|
|
|
if (empty($appointment_id)) {
|
|
$query = "select max(appointment_id) appointment_id from employee_appointment where emp_id = '" . addslashes($_REQUEST['emp_id']) . "' ";
|
|
// echo $query;
|
|
error_log("max appointment_id query: " . $query);
|
|
if (!$result = @mysqli_query($conn, $query)) {
|
|
rollback();
|
|
exit(error_log(mysqli_error($conn)));
|
|
}
|
|
if (mysqli_num_rows($result) > 0) {
|
|
while ($row = mysqli_fetch_assoc($result)) {
|
|
$appointment_id = $row['appointment_id'];
|
|
}
|
|
}
|
|
}
|
|
|
|
$health_program_enrolment_ids = $_REQUEST['health_program_enrolment'];
|
|
$health_program_enrolment_ids = implode(',', $_REQUEST['health_program_enrolment']);
|
|
error_log("health program names " . print_r($health_program_enrolment_ids, true));
|
|
$query_del_waiting_training = " delete from waiting_health_program_enrolment where emp_id = '" . $_REQUEST['emp_id'] . "' and appointment_id = '" . $appointment_id . "' and status='W' ";
|
|
error_log("delete waiting Training: " . $query_del_waiting_training);
|
|
|
|
if (!$result_del = @mysqli_query($conn, $query_del_waiting_training)) {
|
|
|
|
exit(error_log(mysqli_error($conn)));
|
|
rollback();
|
|
}
|
|
|
|
for ($t = 0; $t < count($_REQUEST['health_program_enrolment']); $t++) {
|
|
|
|
$query_insert_waiting_training = " insert into waiting_health_program_enrolment set emp_id = '" . $_REQUEST['emp_id'] . "' , appointment_id = '" . $appointment_id . "', status='W' , training_id='" . $_REQUEST['health_program_enrolment'][$t] . "' ,modified_by='" . $_SESSION["user_id"] . "' ";
|
|
error_log("insert waiting Training: " . $query_insert_waiting_training);
|
|
|
|
if (!$result_insertl = @mysqli_query($conn, $query_insert_waiting_training)) {
|
|
|
|
exit(error_log(mysqli_error($conn)));
|
|
rollback();
|
|
}
|
|
}
|
|
|
|
|
|
// if this is only for saving treatment information we should skip saving OPD information.
|
|
treatment_section:
|
|
|
|
error_log("at treatment section");
|
|
|
|
//lab test saving logic start
|
|
|
|
if ($rolecode == 'DOC' && $_POST['recommended_test_new'] != '' && $_POST['recommended_test_new'] != null) {
|
|
|
|
|
|
|
|
$exists_lab_sql = "select * from checkup_form where appointment_id='" . $appointment_id . "' and followup_id='0'";
|
|
$result_lab_sql = mysqli_query($conn, $exists_lab_sql);
|
|
$num_rows_lab = mysqli_num_rows($result_lab_sql);
|
|
$row_lab_sql = mysqli_fetch_assoc($result_lab_sql);
|
|
|
|
$lab_init_query = "";
|
|
$lab_end_query = "";
|
|
$lab_checkup_ticket_no = "";
|
|
if ($num_rows_lab > 0) {
|
|
$lab_checkup_ticket_no = $row_lab_sql['ticket_no'];
|
|
$lab_init_query = "update checkup_form set ";
|
|
$lab_end_query = " where appointment_id= '" . $appointment_id . "' and checkup_id='" . $row_lab_sql['checkup_id'] . "' and followup_id='0'";
|
|
} else {
|
|
$lab_checkup_ticket_no = creatingCheckupTicketNo();
|
|
$lab_init_query = "insert into checkup_form set appointment_id='" . $appointment_id . "', ";
|
|
$lab_end_query = "";
|
|
}
|
|
|
|
error_log("tests " . $tests_new);
|
|
|
|
$userEntriesArray = explode(",", $tests_new);
|
|
$userEntriesArray = array_map('trim', $userEntriesArray);
|
|
|
|
error_log("user entries array" . $userEntriesArray);
|
|
|
|
// getting checkup lab test master id
|
|
// $checkup_type_id_sql = "select checkup_type_id from checkup_type where checkup_form_section_ids in (select section_id from checkup_form_section where section_name in ('" . join("','", $userEntriesArray) . "'))";
|
|
$checkup_type_id_sql = "select checkup_type_id from checkup_type where checkup_type_code='LAB_TEST'";
|
|
if ($result_checkup = mysqli_query($conn, $checkup_type_id_sql)) {
|
|
error_log("error in getting checkup type id " . mysqli_error($conn) . " query is " . $checkup_type_id_sql);
|
|
}
|
|
$row_checkup = mysqli_fetch_assoc($result_checkup);
|
|
$checkup_type_id = $row_checkup['checkup_type_id'];
|
|
|
|
error_log("checkup type id " . $checkup_type_id);
|
|
// getting checkup lab test master id end -- ----
|
|
|
|
// getting checkup lab section ids
|
|
/*$sql_existing_entries_test = "SELECT group_concat(section_id) as test_id from checkup_form_section where section_name in('" . join("','", $userEntriesArray) . "')";
|
|
|
|
error_log("existing entries query in MRP status:" . $sql_existing_entries_test);
|
|
|
|
if (!$result_existing_entries_test = @mysqli_query($conn, $sql_existing_entries_test)) {
|
|
error_log("error retrieving:" . mysqli_error($conn) . " sql_existing_entries_test:" . $sql_existing_entries);
|
|
}
|
|
$row_test = mysqli_fetch_assoc($result_existing_entries_test);
|
|
$test_section_ids = $row_test['test_id']; */
|
|
// getting checkup lab section id end -----
|
|
$SESSION_emp_id = getTableFieldValue("doctors_master", "doctor_id", "doctor_emp_id", getTableFieldValue("tbl_users", "emp_id", "user_id", $_SESSION["user_id"]));
|
|
// inserting for lab record
|
|
$lab_entry = $lab_init_query . " checkup_date=STR_TO_DATE('" . $appointment_date . "','%d/%m/%Y %h:%i %p') , ticket_no='" . $lab_checkup_ticket_no . "' , emp_id='" . $_REQUEST['emp_id'] . "' , checkup_type_id='" . $checkup_type_id . "' ,referred_by='" . $SESSION_emp_id . "', checkup_section_ids='" . $tests_new . "' , current_status='MRP' , ohc_type_id='" . $_SESSION['current_ohcttype'] . "' , modified_by='" . $_SESSION['user_id'] . "' " . $lab_end_query;
|
|
|
|
error_log("saving lab entry in save opd " . $lab_entry);
|
|
|
|
if (!$result_lab = mysqli_query($conn, $lab_entry)) {
|
|
error_log("error while saving lab entry in save opd " . mysqli_error($conn) . " query is " . $lab_entry);
|
|
}
|
|
}
|
|
|
|
//lab test saving logic end
|
|
|
|
$curr_ohc_id = getTableFieldValue('employee_appointment', 'ohc_type_id', 'appointment_id', $appointment_id);
|
|
if ($_SESSION['current_ohcttype'] == $curr_ohc_id) {
|
|
error_log("getting inside because current ohc is matching with ohc present for this appointment");
|
|
/* for reset Item Stock At Dispensary Level */
|
|
$followup_id = 0;
|
|
if ($_SESSION["RoleCode"] == 'DIS') {
|
|
resetItemStockAtDispensaryLevelForFollowup($appointment_id, $_SESSION['current_ohcttype'], 0);
|
|
} else {
|
|
resetItemStockAtStoreLevelForFollowup($appointment_id, $_SESSION['current_ohcttype'], 0);
|
|
}
|
|
|
|
/* delete all child table during update records */
|
|
if (!@mysqli_query($conn, "delete from appointment_stock_history where appointment_id='" . $appointment_id . "' and followup_id = '" . $followup_id . "'")) {
|
|
|
|
error_log("Exception:" . mysqli_error($conn));
|
|
exit(error_log(mysqli_error($conn)));
|
|
rollback();
|
|
}
|
|
if (!@mysqli_query($conn, "delete from treatment where appointment_id='" . $appointment_id . "' and followup_id = '" . $followup_id . "' ")) {
|
|
|
|
error_log("Exception:" . mysqli_error($conn));
|
|
exit(error_log(mysqli_error($conn)));
|
|
rollback();
|
|
}
|
|
|
|
if ($isTreatmentOnly != 'Y' && !@mysqli_query($conn, "delete from treatment_external where appointment_id='" . $appointment_id . "' and followup_id = '" . $followup_id . "'")) {
|
|
|
|
error_log("Exception:" . mysqli_error($conn));
|
|
exit(error_log(mysqli_error($conn)));
|
|
rollback();
|
|
}
|
|
|
|
/* insert all child table during save or update records */
|
|
|
|
error_log("treatment row count:" . $_REQUEST['count_treatment_item']);
|
|
for ($i = 0; $i <= $_REQUEST['count_treatment_item']; $i++) {
|
|
|
|
error_log("treatment_item:" . $i . ":" . ${"treatment_item$i"});
|
|
|
|
if (${"treatment_item$i"} != null && ${"treatment_item$i"} != "") {
|
|
// To Check Item is Dressing Or Not
|
|
// echo "adarsh";
|
|
$is_dressing_item = toCheckDressingItem(${"treatment_item$i"});
|
|
error_log("is_dressing_item:" . $is_dressing_item);
|
|
|
|
if ($is_dressing_item == 'P') {
|
|
|
|
// echo ${"group_child_flag_$i"};
|
|
if (${"group_child_flag_$i"} == '1') {
|
|
//When found form elements for the group items.. select udpated values from form.
|
|
|
|
$result_for_group_items = getGroupItems(${"treatment_item$i"});
|
|
$no_rows_group_child = mysqli_num_rows($result_for_group_items);
|
|
error_log("no_rows_group_child:" . $no_rows_group_child);
|
|
for ($j = 0; $j < $no_rows_group_child; $j++) {
|
|
$treatment_given_by = '';
|
|
|
|
if (addslashes($_POST['child_item_qty_gvn' . $i . '_' . $j]) != 0 || addslashes($_POST['chihld_item_qty_gvn' . $i . '_' . $j]) != '' || addslashes($_POST['child_item_qty_gvn' . $i . '_' . $j]) != null) {
|
|
$treatment_given_by = ",issue_by='" . $_SESSION['user_id'] . "'";
|
|
}
|
|
|
|
error_log("Child Item:" . $_POST['child_item_' . $i . '_' . $j]);
|
|
$group_item_id = getFieldFromTable('group_id', 'group_items', 'item_id', $_POST['child_item_' . $i . '_' . $j]);
|
|
error_log("group_item_id:" . $group_item_id);
|
|
error_log("childitem:" . $_POST['child_item_' . $i . '_' . $j]);
|
|
$query_treatment = "insert into treatment set appointment_id='" . $appointment_id . "',is_display='N',group_item_id='" . $group_item_id . "', followup_id = '" . $followup_id . "',
|
|
item_id='" . addslashes($_POST['child_item_' . $i . '_' . $j]) . "',item_qty='" . addslashes($_POST['child_item_qty_gvn' . $i . '_' . $j]) . "',
|
|
issued_qty='" . addslashes($_POST['child_item_qty_gvn' . $i . '_' . $j]) . "', modified_by='" . $_SESSION['user_id'] . "'" . $treatment_given_by;
|
|
|
|
error_log("query_treatment: " . $query_treatment);
|
|
if (!$result = @mysqli_query($conn, $query_treatment)) {
|
|
|
|
error_log("Exception:" . mysqli_error($conn));
|
|
error_log("Failed query_treatment: " . $query_treatment);
|
|
rollback();
|
|
exit(error_log(mysqli_error($conn)));
|
|
}
|
|
// echo $query_treatment;
|
|
$query_stock_history = " insert into appointment_stock_history set appointment_id='" . $appointment_id . "', followup_id = '" . $followup_id . "',
|
|
item_qty='" . addslashes($_POST['child_item_qty_gvn' . $i . '_' . $j]) . "', item_id='" . addslashes($_POST['child_item_' . $i . '_' . $j]) . "',
|
|
issued_qty='" . addslashes($_POST['child_item_qty_gvn' . $i . '_' . $j]) . "'" . $treatment_given_by;
|
|
error_log("query_stock_history: " . $query_stock_history);
|
|
if (!@mysqli_query($conn, $query_stock_history)) {
|
|
rollback();
|
|
error_log("issues while updating appointment_stock_history: " . $query_stock_history);
|
|
error_log("Exception:" . mysqli_error($conn));
|
|
exit(mysqli_error($conn));
|
|
}
|
|
// to update Dispensary Items
|
|
if ($_SESSION("RoleCode") == 'DIS') {
|
|
resetItemStockAtDispensaryLevelForGroupItems(-$_POST['child_item_qty_gvn' . $i . '_' . $j], $_POST['child_item_' . $i . '_' . $j], $_SESSION['current_ohcttype']);
|
|
} else {
|
|
resetItemStockAtStoreLevelForGroupItems(-$_POST['child_item_qty_gvn' . $i . '_' . $j], $_POST['child_item_' . $i . '_' . $j], $_SESSION['current_ohcttype'], $_POST['item_batch_no' . $i]);
|
|
}
|
|
}
|
|
} else {
|
|
//When nothing is returned from the form for the group items.. we use the calculated item qty from dressing item definitions
|
|
|
|
|
|
|
|
$result_for_group_items = getGroupItems(${"treatment_item$i"});
|
|
while ($row_for_group_items = mysqli_fetch_array($result_for_group_items)) {
|
|
|
|
$treatment_qty_given_by = '';
|
|
|
|
if ($doctor_attended_flag == 'Y' && (($_SESSION['RoleCode'] == 'DIS') || in_array('DIS', explode(',', $_SESSION['RoleCode'])))) {
|
|
if (addslashes($row_for_group_items['qty']) == 0 || addslashes($row_for_group_items['qty']) == '' || addslashes($row_for_group_items['qty']) == null) {
|
|
$treatment_qty_given_by = ",issue_by='" . $_SESSION['user_id'] . "'";
|
|
error_log('trtr');
|
|
}
|
|
}
|
|
$query_treatment = "insert into treatment set appointment_id='" . $appointment_id . "',is_display='N',group_item_id='" . $row_for_group_items['group_id'] . "',
|
|
item_id='" . addslashes($row_for_group_items['item_id']) . "',item_qty='" . addslashes($row_for_group_items['qty']) . "',followup_id = '" . $followup_id . "',
|
|
issued_qty='" . addslashes($row_for_group_items['qty']) . "', modified_by='" . $_SESSION['user_id'] . "'" . $treatment_qty_given_by;
|
|
|
|
if (!@mysqli_query($conn, $query_treatment)) {
|
|
error_log("issues while updating treatment: " . $query_treatment);
|
|
error_log("Exception:" . mysqli_error($conn));
|
|
rollback();
|
|
exit(mysqli_error($conn));
|
|
}
|
|
// echo $query_treatment;
|
|
$query_stock_history = " insert into appointment_stock_history set appointment_id='" . $appointment_id . "',
|
|
item_qty='" . addslashes($row_for_group_items['qty']) . "', item_id='" . addslashes($row_for_group_items['item_id']) . "',followup_id = '" . $followup_id . "',
|
|
issued_qty='" . addslashes($row_for_group_items['qty']) . "'" . $treatment_qty_given_by;
|
|
if (!@mysqli_query($conn, $query_stock_history)) {
|
|
rollback();
|
|
error_log("Appointment stock history saving error::" . mysqli_error($conn) . "Failed query::" . $query_stock_history);
|
|
exit(mysqli_error($conn));
|
|
}
|
|
}
|
|
}
|
|
} //end for handling of dressing items
|
|
$treatment_qty_given_by = '';
|
|
|
|
|
|
|
|
if ($doctor_attended_flag == 'Y' && (($_SESSION['RoleCode'] == 'DIS') || in_array('DIS', explode(',', $_SESSION['RoleCode'])))) {
|
|
if (addslashes(${"treatment_item_qtygvn$i"}) != 0 || addslashes(${"treatment_item_qtygvn$i"}) != '' || addslashes(${"treatment_item_qtygvn$i"}) != null) {
|
|
$treatment_qty_given_by = ",issue_by='" . $_SESSION['user_id'] . "'";
|
|
|
|
error_log('trtr');
|
|
}
|
|
}
|
|
|
|
$query_treatment = "insert into treatment SET appointment_id='" . $appointment_id . "',
|
|
item_id='" . addslashes(${"treatment_item$i"}) . "',item_qty='" . addslashes(${"dose_qty$i"}) . "',followup_id = '" . $followup_id . "',
|
|
issued_qty='" . addslashes(${"treatment_item_qtygvn$i"}) . "', item_batch_no='" . addslashes(${"item_batch_no$i"}) . "',dosage='" . addslashes(${"dosage$i"}) . "',
|
|
for_days='" . addslashes(${"treatment_item_days$i"}) . "', frequency_id='" . ${"treatment_item_dosage$i"} . "', timing_id = '" . ${"timings$i"} . "',
|
|
dosage_category_id='" . ${"treatment_item_dosage_category$i"} . "', modified_by='" . $_SESSION['user_id'] . "'" . $treatment_qty_given_by;
|
|
error_log("query_treatment: " . $query_treatment);
|
|
if (!$result = @mysqli_query($conn, $query_treatment)) {
|
|
|
|
error_log("Error Saving Treatment data: " . mysqli_error($conn) . " Failed Query:" . $query_treatment);
|
|
rollback();
|
|
exit(mysqli_error($conn));
|
|
}
|
|
|
|
// insert or update the cost details start
|
|
if ($is_dressing_item != 'P') {
|
|
$past_appointment_id = getTableFieldValue('treatment_cost_master', 'appointment_id', 'item_id', ${"treatment_item$i"}, 'appointment_id', $appointment_id);
|
|
|
|
if ($past_appointment_id != "" || $past_appointment_id != null) {
|
|
error_log("update case for cost saving");
|
|
$initquery = "update ";
|
|
$endquery = " where item_id='" . ${"treatment_item$i"} . "' and appointment_id='" . $appointment_id . "'";
|
|
} else {
|
|
$initquery = "insert into ";
|
|
$endquery = "";
|
|
}
|
|
|
|
$present_per_unit_cost = getTableFieldValue('item_cost', 'item_rate_latest', 'ohc_type_id', $_SESSION['current_ohcttype'], 'item_id', ${"treatment_item$i"});
|
|
|
|
$total_cost = round($present_per_unit_cost * ${"treatment_item_qtygvn$i"});
|
|
|
|
error_log("latest rate for item id " . getItemWithFormName(${"treatment_item$i"}) . " " . $present_per_unit_cost . " total sum for this item " . $total_cost);
|
|
|
|
$insert_treatment_cost = $initquery . " treatment_cost_master set appointment_id='" . $appointment_id . "',ohc_type_id='" . $_SESSION['current_ohcttype'] . "',issued_item_cost='" . $total_cost . "',item_id='" . ${"treatment_item$i"} . "' $endquery";
|
|
|
|
error_log("cost saving query for opd " . $insert_treatment_cost);
|
|
|
|
if (!$insert_treatment_cost_result = mysqli_query($conn, $insert_treatment_cost)) {
|
|
error_log("error in cost saving query for opd " . mysqli_error($conn));
|
|
}
|
|
} else {
|
|
|
|
$past_appointment_id = getTableFieldValue('treatment_cost_master', 'appointment_id', 'item_id', ${"treatment_item$i"}, 'appointment_id', $appointment_id);
|
|
|
|
if ($past_appointment_id != "" || $past_appointment_id != null) {
|
|
error_log("update case for cost saving");
|
|
$initquery = "update ";
|
|
$endquery = " where item_id='" . ${"treatment_item$i"} . "' and appointment_id='" . $appointment_id . "'";
|
|
} else {
|
|
$initquery = "insert into ";
|
|
$endquery = "";
|
|
}
|
|
|
|
$present_per_unit_cost = getTableFieldValue('group_items', 'cost', 'group_id', ${"treatment_item$i"});
|
|
|
|
$total_cost = round($present_per_unit_cost * ${"treatment_item_qtygvn$i"});
|
|
|
|
error_log("latest rate for item id " . getItemWithFormName(${"treatment_item$i"}) . " " . $present_per_unit_cost . " total sum for this item " . $total_cost);
|
|
|
|
$insert_treatment_cost = $initquery . " treatment_cost_master set appointment_id='" . $appointment_id . "',ohc_type_id='" . $_SESSION['current_ohcttype'] . "',issued_item_cost='" . $total_cost . "',item_id='" . ${"treatment_item$i"} . "' $endquery";
|
|
|
|
error_log("cost saving query for opd " . $insert_treatment_cost);
|
|
|
|
if (!$insert_treatment_cost_result = mysqli_query($conn, $insert_treatment_cost)) {
|
|
error_log("error in cost saving query for opd " . mysqli_error($conn));
|
|
}
|
|
}
|
|
// insert or update the cost details end
|
|
$treatment_qty_given_by = '';
|
|
|
|
|
|
if ($doctor_attended_flag == 'Y' && (($_SESSION['RoleCode'] == 'DIS') || in_array('DIS', explode(',', $_SESSION['RoleCode'])))) {
|
|
if (addslashes(${"treatment_item_qtygvn$i"}) != 0 || addslashes(${"treatment_item_qtygvn$i"}) != '' || addslashes(${"treatment_item_qtygvn$i"}) != null) {
|
|
$treatment_qty_given_by = ",issue_by='" . $_SESSION['user_id'] . "'";
|
|
error_log('trtr');
|
|
}
|
|
}
|
|
$query_stock_history = " insert into appointment_stock_history set appointment_id='" . $appointment_id . "', current_stock='" . addslashes(${"current_stock$i"}) . "',item_qty='" . addslashes(${"frequency_qty$i"}) . "', item_id='" . addslashes(${"treatment_item$i"}) . "',issued_qty='" . addslashes(${"treatment_item_qtygvn$i"}) . "' ,followup_id = '" . $followup_id . "'" . $treatment_qty_given_by;
|
|
error_log(" appointment_stock_history update details: " . $query_stock_history);
|
|
if (!@mysqli_query($conn, $query_stock_history)) {
|
|
rollback();
|
|
error_log("Error updating appointment_stock_history: " . $query_stock_history);
|
|
error_log("Exception:" . mysqli_error($conn));
|
|
exit(error_log(mysqli_error($conn)));
|
|
}
|
|
|
|
if (${"group_child_flag_$i"} != '1')
|
|
updaterItemStock($_SESSION['current_ohcttype'], addslashes(${"treatment_item$i"}), ${"treatment_item_qtygvn$i"}, ${"item_batch_no$i"});
|
|
|
|
|
|
|
|
/*
|
|
* //$item_batch_no=getMinExpiaryDateItem($_SESSION['current_ohcttype'], addslashes(${"treatment_item$i"}));
|
|
* $current_stock_qty=getStockQtyAtDispensaryLevel(${"treatment_item$i"},$_SESSION['current_ohcttype']);
|
|
* // echo $current_stock_qty;
|
|
* $stock_qty = floatval ( $current_stock_qty ) - (floatval ( ${"treatment_item_qtygvn$i"} ));
|
|
* //echo $stock_qty;
|
|
* $current_stock_query = "update item_stock_dispensary set stock_qty='".$stock_qty."' where item_id='".${"treatment_item$i"}."' and item_batch_no='".$item_batch_no."' and ohc_location_id='".$_SESSION['current_ohcttype']."' ";
|
|
* // echo $current_stock_query;
|
|
* mysqli_query($conn,$current_stock_query );
|
|
*/
|
|
} else if ($isTreatmentOnly != 'Y' && ${"treatment_item_external$i"} != null && ${"treatment_item_external$i"} != "") {
|
|
|
|
$query_treatment = "insert into treatment_external SET appointment_id='" . $appointment_id . "',followup_id = '" . $followup_id . "',
|
|
item_name='" . addslashes(${"treatment_item_external$i"}) . "',item_qty='" . addslashes(${"dose_qty$i"}) . "',timing = '" . addslashes(${"timings$i"}) . "',dosage='" . addslashes(${"treatment_item_dosage$i"}) . "',
|
|
for_days='" . addslashes(${"treatment_item_days$i"}) . "', dosage_category_id='" . ${"treatment_item_dosage_category$i"} . "', modified_by='" . $_SESSION['user_id'] . "' ";
|
|
|
|
if (!@mysqli_query($conn, $query_treatment)) {
|
|
|
|
error_log("error saving treamemnt external : " . $query_treatment);
|
|
error_log("Exception:" . mysqli_error($conn));
|
|
|
|
exit(error_log(mysqli_error($conn)));
|
|
rollback();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
commit();
|
|
$data['followup_id'] = $followup_id;
|
|
$data['appointment_id'] = $appointment_id;
|
|
|
|
// error_log(print_r($data), true);
|
|
echo json_encode($data);
|