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

556 lines
18 KiB
PHP

<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<div id="opd_form_div" style="display:none">
<form id="opd_form" name="opd_form">
<?php
//include autoloader;
include('includes/config/config.php');
include_once("includes/functions.php");
error_reporting(E_ERROR | E_PARSE);
error_log("id:" . $_REQUEST['appointment_idpdf']);
$appoint_id = $_REQUEST['appointment_idpdf'];
// $sql_employee_appointment = "SELECT a.*, p.* from employee_appointment a, patient_master p where a.emp_id=p.id and appointment_id='" . $_REQUEST['appointment_idpdf'] . "'";
$sql_employee_appointment = "SELECT a.*, p.patient_name, p.dept_id, p.emp_code, p.father_name, p.designation_id,employer_contractor_id, patient_cat_id, gender,blood_group,emp_cadre,dob,p.dept_id,p.bu_id,p.section_id,p.bu_id,p.sub_section_id , p.primary_phone , p.designation_id , p.status , p.emp_mgr_code
FROM employee_appointment AS a
INNER JOIN patient_master AS p ON a.emp_id = p.id
WHERE a.appointment_id = '" . $_REQUEST['appointment_idpdf'] . "'";
error_log("sql injury pres:" . $sql_employee_appointment);
$res_emp_appoint = mysqli_query($conn, $sql_employee_appointment);
$row = mysqli_fetch_array($res_emp_appoint);
@extract($row);
$sqlOfSickness = "SELECT DATE_FORMAT(date_absent,'%d-%m-%Y') as rest_from , DATE_FORMAT(date_absent_to,'%d-%m-%Y') as rest_to , DATE_FORMAT(approval_date,'%d-%m-%Y') as approval_date , `des` , fitness_status FROM sickness WHERE followup_to_opd = '" . $_REQUEST['appointment_idpdf'] . "' ";
error_log("sqlOfSickness:" . $sqlOfSickness);
$resultOfSickness = mysqli_query($conn, $sqlOfSickness);
$fetchSicknessData = mysqli_fetch_assoc($resultOfSickness);
$restPeriodFrom = $fetchSicknessData['rest_from'];
$restPeriodTo = $fetchSicknessData['rest_to'];
$SicknessApprovalDate = $fetchSicknessData['approval_date'];
$SicknessDes = $fetchSicknessData['des'];
$SicknessFitnessStatus = $fetchSicknessData['fitness_status'];
$patient_name = $row['patient_name'];
$attended_doc = $row['doctor_last_attended'];
$doc_user_id = ($attended_doc != null && $attended_doc != 0 && $attended_doc != "") ? $attended_doc : $row['modified_by'];
$doc_emp_id = getTableFieldValue('tbl_users', 'emp_id', 'user_id', $doc_user_id, '');
error_log("DOC EMP ID : " . $doc_emp_id);
$doc_name = getTableFieldValue('patient_master', 'patient_name', 'id', $doc_emp_id, '');
// $result = mysqli_query($conn, $query);
// $row = mysqli_fetch_array($result);
@extract($row);
$sql_doc_details = "select * from employee_signature where emp_id='$doc_emp_id'";
$result_doc_details = mysqli_query($conn, $sql_doc_details);
$row_doc_details = mysqli_fetch_array($result_doc_details);
$employee_code = $row['emp_code'];
$father_name = $row['father_name'];
if ($row['IsEmergency'] == 1) {
$ans = "Yes";
} else {
$ans = "No";
}
date_default_timezone_set('Asia/Kolkata');
$date = date('Y-m-d H:i:s');
$currentDate = date_format(date_create($date), "d-M-Y h:i:sa ");
$ailment_names = $row['ailments_new'];
$ailment_system_name = $row['ailment_systems_new'];
$injury_part_names = $row['injury_parts_new'];
$health_advices = $row['health_advices_new']; //getCommaSeperatedValuesForInClause("select health_advice_name from health_advice ","health_advice_id",$row['health_advices']);
$tests = $row['recommended_tests_new']; //getCommaSeperatedValuesForInClause("select section_name from checkup_form_section ","section_id",$row['tests']);
?>
<style>
body {
text-transform: capitalize;
}
.tbl1 {
width: 100%;
}
th {
background-color: #e1e1e1;
font-size: 12px;
font-style: bold;
vertical-align: top;
}
td {
text-align: left;
font-size: 12px;
vertical-align: top;
}
</style>
</head>
<body>
<?php
include('new_pdf_header.php');
?>
<table border="1" cellspacing="0" width="100%">
<tr>
<th colspan="3" align="center" style="font-size: 20px;background-color: #243557;color: white">
Injury Intimation Form</th>
</tr>
<tr>
<th colspan="3">Reporting Time in OHC: <?php
if ($row['clearance_time'] !='') {
echo date("G:i", strtotime($row['clearance_time'])) ?>
<span style="margin-left: 350px">Clearance Date:
<?php
echo date("d-m-Y", strtotime($row['clearance_time'])) ;
}
?></span>
</th>
</tr>
<tr>
<td rowspan="8" style="text-align: center; vertical-align: middle;">
<img style="width: 170px; height: 170px;" src="data:<?php echo $row['emp_image_type'] ?>;base64,<?php echo base64_encode($row['emp_photo']) ?>" />
</td>
<td colspan="1">Name Of Patient</td>
<td colspan="1"><?php echo $patient_name; ?></td>
</tr>
<tr>
<td colspan="1">Employee ID : </td>
<td>
<?php echo $row['emp_code'] ?>
</td>
</tr>
<td colspan="1">Age of Patient :</td>
<td>
<?php
if ($row['dob'] != '0000-00-00' && $row['dob'] != '1970-01-01' && $row['dob'] != null && $row['dob'] != '') {
echo calculateAge($row['dob']);
}
?>
</td>
</tr>
<tr>
<td colspan="1">Gender </td>
<td>
<?php if ($row['gender'] == 'M') {
echo 'Male';
} else {
echo 'Female';
} ?>
</td>
</tr>
<tr>
<td colspan="1">Individual Contact No.</td>
<td colspan="1"><?php echo $row['primary_phone'] ?></td>
</tr>
<tr>
<td colspan="1">Designation and employment status</td>
<td colspan="1">
<?php echo getTableFieldValue('designation', 'designation_name', 'designation_id', $row['designation_id']) ?>
, <?php echo $row['status'] ?></td>
</tr>
<tr>
<td colspan="1">Division/Department/Station</td>
<td colspan="1">
<?php echo getTableFieldValue('bussiness_unit', 'bu_name', 'bu_id', $row['bu_id']) ?>/<?php echo getTableFieldValue('department', 'dept_name', 'dept_id', $row['dept_id']) ?>/<?php echo getTableFieldValue('section', 'section_name', 'section_id', $row['section_id']) ?>
</td>
</tr>
<tr>
<td colspan="1">Name Of Supervisor and Contact no</td>
<td colspan="1">
<?php echo getTableFieldValue('patient_master', 'patient_name', 'id', $row['emp_mgr_code']) ?>
<?php
$phoneOfSupervisor = getTableFieldValue('patient_master', 'primary_phone', 'id', $row['emp_mgr_code']);
if ($phoneOfSupervisor != '') {
echo " - " . $phoneOfSupervisor;
}
?></td>
</tr>
<tr>
<th align="center" colspan="3">OCCURANCE OF INJURY</th>
</tr>
<tr>
<td colspan="1">Injury Time : <?php echo date("G:i", strtotime($row['injury_time'])) ?></td>
<td colspan="1">Date : <?php echo date("d-m-Y", strtotime($row['appointment_date'])) ?></td>
<td colspan="1">Shift : <?php echo $row['shift_type'] ?></td>
</tr>
<tr>
<td colspan="1">Activity</td>
<td colspan="2">
<?php if (strcmp($row['injury_area_cat'], 'IN') == 0) {
echo "Work Related";
}
if (strcmp($row['injury_area_cat'], 'NIN') == 0) {
echo "Non Work Related";
} ?>
</td>
</tr>
<tr>
<td colspan="1">PPE</td>
<td colspan="2">
<?php echo $row['ppe'] ?>
</td>
</tr>
<tr>
<td colspan="1">Location of Injury</td>
<td colspan="2"><?php echo $row['incident_location'] ?></td>
</tr>
<?php
$injury_type_names = explode(',', $row['injury_types_new']);
$injury_part_names = explode(',', $row['injury_parts_new']);
// error_log("injury part name: ".print_r($injury_part_names, true)." length: ".count($injury_part_names));
$injury_class_names = explode(',', $row['injury_classes_new']);
?>
<tr>
<td width="50%">Injury Category
</td>
<td width="50%"><?php
foreach ($injury_class_names as $injury_class_name) { ?>
<span><?php echo strtoupper(getTableFieldValue('injury_class', 'inj_class_name', 'inj_class_id', $injury_class_name)); ?>,&nbsp;&nbsp;</span>
<?php }
?>
</td>
<td></td>
</tr>
<tr>
<td width="50%">Injury Type </span>
</td>
<td width="50%"><?php
foreach ($injury_type_names as $injury_type_name) { ?>
<span><?php echo strtoupper(getTableFieldValue('injury_type', 'injury_type_name', 'injury_type_id', $injury_type_name)); ?>,&nbsp;&nbsp;</span>
<?php }
?>
</td>
<td></td>
</tr>
<tr>
<td width="50%">Body part classification</td>
<?php $injury_parts_ids = $row['injury_parts_new'];
$injury_parts_ids_array = array();
$injury_parts_ids_array = explode(",", $injury_parts_ids);
error_log("injury part " . $injury_parts_ids_array);
$injury_part_names = "";
for ($i = 0; $i < count($injury_parts_ids_array); $i++) {
if ($i == 0) {
$injury_part_names = getTableFieldValue('injury_part', 'inj_name', 'inj_id', $injury_parts_ids_array[$i]);
} else {
$injury_part_names = $injury_part_names . "," . getTableFieldValue('injury_part', 'inj_name', 'inj_id', $injury_parts_ids_array[$i]);
}
} ?>
<td width="50%" colspan="2"><?php echo $injury_part_names; ?></td>
</tr>
<tr>
<td width="50%">Injury Mechanism</td>
<td width="50%" colspan="2">
<?php echo getTableFieldValue('injury_mechanism', 'injury_mech_name', 'injury_mech_id', $row['injury_mech']) ?>
</td>
</tr>
<!-- <tr>
<td width="50%" height="3%">Descriprtion of incident</td>
<td width="50%" colspan="2" height="3%"><?php echo $row['remarks_rece'] ?></td>
</tr> -->
<tr>
<td width="50%">Follow Up</td>
<td width="50%" colspan="2">
<?php
if ($row['followup'] != "" && $row['followup'] != '0000-00-00') {
echo date_format(date_create($row['followup']), "d-m-Y");
}
error_log("follow up: " . $row['followup']);
?>
</td>
</tr>
<tr>
<td width="50%">Period Of Rest</td>
<td width="50%" colspan="2">
<?php
// echo $row['rest_from_time'] . " Dushant" ;
if (!empty($restPeriodFrom) && !empty($restPeriodTo)) {
echo "From " . date_format(date_create($restPeriodFrom), "d-m-Y") . " To " . date_format(date_create($restPeriodTo), "d-m-Y");
}
// if ($row['rest_from_time'] != "0000-00-00 00:00:00" && $row['rest_to_time'] != "0000-00-00" && $row['rest_from_time'] != "" && $row['rest_to_time'] != "") {
// echo "From " . date_format(date_create($row['rest_from_time']), "d-m-Y") . " To " . date_format(date_create($row['rest_to_time']), "d-m-Y");
// }
// error_log("rest_from_time : " . $row['rest_from_time'] . " rest_to_time : " . $row['rest_to_time']);
?>
</td>
</tr>
<tr>
<td width="50%">Referral</td>
<td width="50%" colspan="2">
<?php echo nl2br(($row['referral'] != '') ? getCommaSeperatedValuesForInClause("select referral_point_name from referral_point ", "referral_point_id ", $row['referral']) : "N/A") ?>
</td>
</tr>
<tr>
<td width="50%">
Referral Conclusion
</td>
<td width="50%" colspan="2">
<?php echo nl2br(($row['referral_consultation'] != '') ? $row['referral_consultation'] : "N/A") ?>
</td>
</tr>
<tr>
<td width="100%" colspan="3" height="8%">
<b><u>OHC Staff Notes:</u></b> <?= $row['remarks_rece'] ?>
</td>
</tr>
<tr style="border-bottom: none;">
<td width="100%" colspan="3" style="border-bottom: none;"><b><u>Treatments:</u></b> </td>
</tr>
<tr style="border-top: none;">
<td width="100%" colspan="3" style="border-top: none;"> <?php include('treatment_view_common.php'); ?></td>
</tr>
<tr>
<td width="100%" colspan="3" height="5%"><b><u>Remark By Medical Officer :</u></b>
<?php echo $row['injury_remarks'] ?><br><br><br><br><span style="margin-left: 550px;"></td>
</tr>
<?php
if (!empty($SicknessApprovalDate)) {
?>
<tr>
<td width="100%" colspan="3" height="5%">
<b>
<u>
Fitness Report
</u>
</b>
<br>
<br>
<span> <strong> Is FIT : </strong> YES </span> &nbsp; || &nbsp; <strong>Fitness Date :</strong> <?php echo $SicknessApprovalDate ?> &nbsp; || &nbsp; <strong> Health Status : </strong> <?php echo $SicknessDes ?> &nbsp; || &nbsp; <strong>Approval Status :</strong> <?php echo $SicknessFitnessStatus ?> &nbsp; &nbsp;
</td>
</tr>
<?php } ?>
</table>
<!-- <table width="100%">
<tr>
<td>
<?php if ($row_doc_details['emp_sign'] != '' || $row_doc_details['emp_sign'] != null) { ?>
<img src="data:<?php echo $row_doc_details['image_type'] ?>;base64,<?php echo base64_encode($row_doc_details['emp_sign']) ?>" style="width: 120px; height: 80px;float: right" />
</td>
<?php } ?>
</tr>
</table> -->
<br>
<table width="100%">
<tr>
<td><img src="data:<?php echo $row_doc_details['image_type'] ?>;base64,<?php echo base64_encode($row_doc_details['emp_sign']) ?>" style="width: 120px; height: 80px;float: right" /></td>
</tr>
</table>
<br>
<br>
<br>
<br>
<table width="100%">
<tr>
<td>
<span style="float: right;">Signature & Stamp</span>
</td>
</tr>
</table>
<br>
<table width="100%">
<tr>
<td><span style="float: right;">
<?php
echo $doc_name . " ," . $row_doc_details['qualification'];
?>
</span></td>
</tr>
</table>
<br>
<table width="100%">
<tr>
<td><span style="float: right;">KMC Reg No:
<?php echo $row_doc_details['registration_no'] ?>
</span>
</td>
</tr>
</table>
<?php
if (!empty($_REQUEST['appointment_idpdf'])) {
$sqlShowImages = " SELECT * FROM injury_image WHERE `injury_id` = '" . $_REQUEST['appointment_idpdf'] . "'";
$resultShowImages = mysqli_query($conn, $sqlShowImages);
while ($rowShowImages = mysqli_fetch_assoc($resultShowImages)) { ?>
<img style="display: inline-block; height: 300px; width: 300px; margin: 10px;" src="data:<?php echo $rowShowImages['image_type']; ?>;base64,<?php echo base64_encode($rowShowImages['image']); ?>" alt="">
<?php
}
}
?>
</form>
<?php
if($_REQUEST['attachment'] == 'pdf'){?>
<form id="employeeDetailsFormPdf" action="" method="POST">
<input type="text" name="htmlText" id="htmlText" />
<input type="hidden" name="param" id="param" value="<?php echo $patient_name . "_" ."INTIMATION" ?>" />
<input type="hidden" name="param_value" id="param_value" value="<?php echo $appoint_id ?>" />
</form>
<script>
formSubmit();
function formSubmit() {
$("#htmlText").val($("#opd_form").html());
document.forms['employeeDetailsFormPdf'].action = "generate_html_pdf.php";
document.forms['employeeDetailsFormPdf'].method = "post";
document.forms['employeeDetailsFormPdf'].submit();
// window.close();
}
setTimeout(function() {
window.close();
}, 3000);
</script>
<?php
} else{
?>
<form id="employeeDetailsFormPdf" action="" method="POST">
<input type="hidden" name="htmlText" id="htmlText" />
</form>
</div>
<script>
formSubmit();
function formSubmit() {
$("#htmlText").val($("#opd_form").html());
document.forms['employeeDetailsFormPdf'].action = "pdf_dynamic.php";
document.forms['employeeDetailsFormPdf'].method = "post";
document.forms['employeeDetailsFormPdf'].submit();
}
</script>
<?php
}
?>