ESH/daily_case_report_FTD_pdf.php
2024-10-23 18:28:06 +05:30

322 lines
15 KiB
PHP

<?php //include('pdf_header_reverse.php');
include('includes/config/config.php');
include('includes/functions.php');
//include('pop_up_top.php');
$startDate = date('Y-m-d', strtotime($_POST['startopdDate']));
$endDate = date('Y-m-d', strtotime($_POST['endopdDate']));
// $from_date = date('d-m-Y', strtotime($from_date1));
error_log("start date ".$startDate);
error_log("end date ".$endDate);
$ohc = $_SESSION['current_ohcttype'];
?>
<link href="includes/css-js/admin.css" rel="stylesheet" type="text/css" />
<style>
@page {
margin: 15px;
}
.btn {
background-color: #4CAF50;
border-radius: 5%;
/* Green */
border: none;
color: white;
padding: 5px 8px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 12px;
margin: 4px 2px;
cursor: pointer;
}
@media print {
#printPageButton {
display: none;
}
}
</style>
<body>
<?php include('pdf_ohc_header.php'); ?>
<table width="100%">
<tr>
<td style="font-size: 15px;"><strong style="margin-left: 400px">Daily Cases Report</strong></td>
</tr>
<tr>
<td align="left" style="font-size: 12px"><strong>From Date: <? echo date("d-M-Y", strtotime($startDate)); ?></strong></td>
<td align="right" style="font-size: 15px"><button align="center" id="printPageButton" class="btn btn-success" onClick="window.print();">Print</button></td>
</tr>
</table>
<br>
<table border="1" width="100%" cellspacing="0">
<?php
$sqll = "SELECT count(*) as total FROM employee_appointment a JOIN patient_master b on a.emp_id=b.id WHERE a.ohc_type_id='" . $_SESSION['current_ohcttype'] . "' and date(a.appointment_date) between STR_TO_DATE('" . $startDate . "', '%Y-%m-%d') AND STR_TO_DATE('" . $endDate . "', '%Y-%m-%d')";
$result_sqll = mysqli_query($conn, $sqll);
$num_rows = mysqli_num_rows($result_sqll);
$row0 = mysqli_fetch_assoc($result_sqll);
error_log("total:" . $sqll);
$sql = "SELECT DATE_FORMAT(a.appointment_date, '%d-%m-%y') as date,a.*,b.* FROM employee_appointment a JOIN patient_master b on a.emp_id=b.id WHERE date(a.appointment_date) between STR_TO_DATE('" . $startDate . "', '%Y-%m-%d') AND STR_TO_DATE('" . $endDate . "', '%Y-%m-%d') and a.ohc_type_id='" . $_SESSION['current_ohcttype'] . "' order by a.appointment_date ASC";
error_log($sql);
$result = mysqli_query($conn, $sql);
?>
<strong>
<tr bgcolor="#eeeeee">
<td align="left" width="2%">Sr.</td>
<td align="left" width="3%">Date</td>
<td align="left" width="3%">Time In</td>
<td align="left" width="3%">Time Out</td>
<td align="left" width="2%">Duration</td>
<td valign="top" align="left" width="2%">Shift</td>
<td valign="top" align="left" width="8%">Name</td>
<td valign="top" align="left" width="2%">Age</td>
<td valign="top" align="left" width="2%">Sex</td>
<td valign="top" align="left" width="3%">Case Type</td>
<td valign="top" align="left" width="3%">Disease Type</td>
<td valign="top" align="left" width="3%">Referred By</td>
<td valign="top" align="left" width="3%">Referred To</td>
<td valign="top" align="left" width="5%">Mobile No.</td>
<td valign="top" align="left" width="3%">Emp. No.</td>
<td valign="top" align="left" width="3%">Employer</td>
<td valign="top" align="left" width="5%">Designation</td>
<td valign="top" align="left" width="3%">Division</td>
<td valign="top" align="left" width="3%">Department</td>
<td valign="top" align="left" width="3%">Station/Lane</td>
<td valign="top" align="left" width="3%">Body System</td>
<td valign="top" align="left" width="3%">Chief Complaints</td>
<td valign="top" align="left" width="3%">MIS</td>
<td valign="top" align="left" width="3%">Communicable/Non-Coummnicable</td>
<td valign="top" align="left" width="5%">Treatment</td>
<td valign="top" align="left" width="5%">Remarks</td>
</tr>
<?php
$count = 1;
while ($row1 = mysqli_fetch_assoc($result)) {
extract($row1);
// error_log($row1['employer_contractor_id']);
?>
<tr>
<td><?php echo $count ?></td>
<td><?php echo $row1['date'] ?></td>
<td><?php echo date("d/M/Y H:i ", strtotime($row1['appointment_date'])) ?></td>
<td><?php if ($row1['clearance_time'] != null && $row1['clearance_time'] != '' && $row1['clearance_time'] != "00-00-00 00:00:00")
echo date("d/M/Y H:i ", strtotime($row1['clearance_time'])) ?></td>
<td><?php
if ($row1['clearance_time'] != null && $row1['clearance_time'] != '' && $row1['clearance_time'] != "00-00-00 00:00:00") {
$from = strtotime($row1['appointment_date']);
$to = strtotime($row1['clearance_time']);
$diff = abs($to - $from);
// To get the year divide the resultant date into
// total seconds in a year (365*60*60*24)
$years = floor($diff / (365 * 60 * 60 * 24));
// To get the month, subtract it with years and
// divide the resultant date into
// total seconds in a month (30*60*60*24)
$months = floor(($diff - $years * 365 * 60 * 60 * 24)
/ (30 * 60 * 60 * 24));
// To get the day, subtract it with years and
// months and divide the resultant date into
// total seconds in a days (60*60*24)
$days = floor(($diff - $years * 365 * 60 * 60 * 24 -
$months * 30 * 60 * 60 * 24) / (60 * 60 * 24));
// To get the hour, subtract it with years,
// months & seconds and divide the resultant
// date into total seconds in a hours (60*60)
$hours = floor(($diff - $years * 365 * 60 * 60 * 24
- $months * 30 * 60 * 60 * 24 - $days * 60 * 60 * 24)
/ (60 * 60));
// To get the minutes, subtract it with years,
// months, seconds and hours and divide the
// resultant date into total seconds i.e. 60
$minutes = floor(($diff - $years * 365 * 60 * 60 * 24
- $months * 30 * 60 * 60 * 24 - $days * 60 * 60 * 24
- $hours * 60 * 60) / 60);
// To get the minutes, subtract it with years,
// months, seconds, hours and minutes
$seconds = floor(($diff - $years * 365 * 60 * 60 * 24
- $months * 30 * 60 * 60 * 24 - $days * 60 * 60 * 24
- $hours * 60 * 60 - $minutes * 60));
error_log('year' . $months);
// Print the result
if ($years != 0 || $years != '0') printf($years . " year,",);
if ($months != 0 || $months != '0') echo ($months . " month,");
if ($days != 0 || $days != '0') echo ($days . " day,");
if ($hours != 0 || $hours != '0') echo ($hours . " hours,");
if ($minutes != 0 || $minutes != '0') echo ($minutes . " minutes,");
if ($seconds != 0 || $seconds != '0') echo ($seconds . " seconds,");
} ?>
</td>
<td><?php echo $row1['shift_type'] ?></td>
<td><?php echo $row1['patient_name'] ?></td>
<td><?php
$from = new DateTime($row1['dob']);
$to = new DateTime('today');
echo $from->diff($to)->y;
?></td>
<td><?php if ($row1['gender'] == 'M') {
echo 'Male';
} else {
echo 'Female';
} ?></td>
<td><?php if (strcmp($row1['case_type'], 'NEW') == 0) {
echo 'NEW CASE';
}
if (strcmp($row1['case_type'], 'REP') == 0) {
echo 'REPEAT';
}
if (strcmp($row1['case_type'], 'FUP') == 0) {
echo 'FOLLOW UP';
}
if (strcmp($row1['case_type'], 'MED') == 0) {
echo 'MEDICATION';
} ?></td>
<td><?php if ($row1['disease_type'] == 'COMM') {
echo 'Communicable';
} else if ($row1['disease_type'] == 'NON-COMM') {
echo 'Non-Communicable';
} ?>
</td>
<td><?php echo getFieldFromTable('referred_by', 'referred_by_master', 'id', $row1['referred_by']); ?></td>
<td><?php if (strcmp($row1['referred_to'], 'DEPT') == 0) {
echo 'DEPARTMENT';
}
if (strcmp($row1['referred_to'], 'HR') == 0) {
echo 'HR';
}
if (strcmp($row1['referred_to'], 'IR') == 0) {
echo 'IR';
}
if (strcmp($row1['referred_to'], 'HOS') == 0) {
echo 'HOSPITAL';
} ?></td>
<td><?php echo $row1['primary_phone'] ?></td>
<td><?php echo $row1['emp_code'] ?></td>
<td><?php echo getFieldFromTable('employer_contractor_name','employer_contractor','id' ,$row1['employer_contractor_id'])?></td>
<!-- <td><?php echo $row1['patient_name'] ?></td> -->
<td><?php echo getTableFieldValue('designation', 'designation_name', $row1['designation_id'], 'designation_id',) ?>
</td>
<!-- <td><?php
$from = new DateTime($dob);
$to = new DateTime('today');
echo $from->diff($to)->y;
?></td> -->
<td><?php echo getTableFieldValue('bussiness_unit', 'bu_name', $row1['bu_id'], 'bu_id') ?></td>
<td><?php echo getTableFieldValue('department', 'dept_name', $row1['dept_id'], 'dept_id') ?></td>
<td><?php echo getTableFieldValue('sub_section', 'sub_section_name', $row1['sub_section_id'], 'sub_section_id') ?>
</td>
<td><?php echo getTableFieldValue('ailment_system', 'ailment_sys_name', 'ailment_sys_id', $row1['ailment_systems_new']) ?>
</td>
<?php
$complaint_ids = $row1['complaints'];
$complaint_ids_array = array();
$complaint_ids_array = explode(",", $complaint_ids);
$complaints = "";
for ($i = 0; $i < count($complaint_ids_array); $i++) {
if ($i == 0) {
if (is_numeric($complaint_ids_array[$i])) {
$complaints = getTableFieldValue('complaints', 'complaint', 'complaint_id', $complaint_ids_array[$i]);
} else {
$complaints = $complaint_ids_array[$i];
}
} else {
if (is_numeric($complaint_ids_array[$i])) {
$complaints = $complaints . "," . getTableFieldValue('complaints', 'complaint', 'complaint_id', $complaint_ids_array[$i]);
} else {
$complaints = $complaints . "," . $complaint_ids_array[$i];
}
}
}
?>
<td><?php echo $complaints ?></td>
<td><?php if (strcmp($row1['clinical_opinion'], 'OC') == 0) {
echo 'OCCUPATIONAL CASE';
}
if (strcmp($row1['clinical_opinion'], 'ORC') == 0) {
echo 'OCCUPATION RELATED CASE';
}
if (strcmp($row1['clinical_opinion'], 'NOC') == 0) {
echo 'NON OCCUPATIONAL COMMUNICABLE';
}
if (strcmp($row1['clinical_opinion'], 'NONC') == 0) {
echo 'NON OCCUPATIONAL NON COMMUNICABLE';
}
if (strcmp($row1['clinical_opinion'], 'IC') == 0) {
echo 'INJURY CASE';
}
if (strcmp($row1['clinical_opinion'], 'SCC') == 0) {
echo 'SAFETY CONCERN CASE';
}
if (strcmp($row1['clinical_opinion'], 'SEN') == 0) {
echo 'SENSITIZATION';
}
if (strcmp($row1['clinical_opinion'], 'OM') == 0) {
echo 'OHC MANAGEMENT';
}
if (strcmp($row1['clinical_opinion'], 'ER') == 0) {
echo 'EXT REFERRAL';
}
if (strcmp($row1['clinical_opinion'], 'ONC') == 0) {
echo 'ONGOING CASE';
} ?></td>
<td><?php if (strcmp($row1['disease_type'], 'COMM') == 0) {
echo 'COMMUNICABLE';
}
if (strcmp($row1['disease_type'], 'NON-COMM') == 0) {
echo 'NON-COUMMUNICABLE';
} ?></td>
<td><?php echo $treatment_text = getTreatmentText($row1['appointment_id']); ?></td>
<td><?php echo $row1['remarks_rece'] ?></td>
</tr>
<?php
$count++;
}
?>
<tr Height="10px">
<td colspan="25"><b>TOTAL: &nbsp;<?php echo $row0['total'] ?></b></td>
</tr>
</table>
</body>
<script>
$(document).ready(function() {
window.print();
});
</script>