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

218 lines
9.9 KiB
PHP

<?php //include('pdf_header_reverse.php');
include('includes/config/config.php');
include('includes/functions.php');
header("Content-type:application/octet-stream");
header("Content-type: application/x-msdownload");
header("Content-Disposition: attachment; filename=opd_report_excel.xls");
header("Pragma: no-cache");
header("Expires: 0");
$start = $_POST['ehc_startDate'];
$end = $_POST['ehc_endDate'];
?>
<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('excel_ohc_header.php'); ?>
<table width="100%">
<tr>
<td align="center" style="font-size: 18px;color:red"><strong>Executive Follow-Up Report</strong></td>
</tr>
<tr>
<td align="left" style="font-size: 12px"><strong>(For Interval:
<?php echo $start."-".$end ; ?>)</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">
<tr bgcolor="#eeeeee">
<td align="left" width="2%"><strong><?=$count?></td>
<td align="left" width="5%"><strong>Medical Exam. Date</td>
<td align="left" width="2%"><strong>Follow-up Date</td>
<td align="left" width="4%"><strong>Name</td>
<td align="left" width="3%"><strong>ECode/G.Pass</td>
<td valign="top" align="left" width="5%"><strong>Designation</td>
<td valign="top" align="left" width="4%"><strong>Devision</td>
<td valign="top" align="left" width="4%"><strong>Department</td>
<td valign="top" align="left" width="3%"><strong>Ute</td>
<td valign="top" align="left" width="5%"><strong>Section</td>
<td valign="top" align="left" width="4%"><strong>Mobile No.</td>
<td valign="top" align="left" width="5%"><strong>Case Type</td>
<td valign="top" align="left" width="5%"><strong>Complaints</td>
<td valign="top" align="left" width="5%"><strong>Diagnosis</td>
<td valign="top" align="left" width="5%"><strong>Body System</td>
<td valign="top" align="left" width="2%"><strong>Disease Type</td>
<td valign="top" align="left" width="8%"><strong>Treatment</td>
<td valign="top" align="left" width="3%"><strong>Health Advice</td>
<td valign="top" align="left" width="8%"><strong>Additional Recommendation if any</td>
<td valign="top" align="left" width="5%"><strong>Ecg Finding</td>
<td valign="top" align="left" width="5%"><strong>Doctor Recommended Test</td>
<td valign="top" align="left" width="5%"><strong>Additional Precaution</td>
<td valign="top" align="left" width="8%"><strong>Follow-up Remark if Any<strong></td>
</tr>
<?php
$count=1;
$appints=array();
$emp_ids=array();
$examination_finded_arr= array();
$sqll = "select DISTINCT emp_id from checkup_form where date_format(date(checkup_date),'%Y-%m-%d') between STR_TO_DATE('".$start."','%d-%m-%Y') and STR_TO_DATE('".$end."','%d-%m-%Y');";
$result_sqll = mysqli_query($conn,$sqll);
$num_rows = mysqli_num_rows($result_sqll);
while( $row0 = mysqli_fetch_assoc($result_sqll)){
array_push($emp_ids,$row0['emp_id']);
}
// $emp_ids=array_unique($emp_ids);
error_log('emp arr'.print_r($emp_ids,true).print_r(count($emp_ids),true));
for($i=0;$i<count($emp_ids);$i++){
$empid=$emp_ids[$i];
$sql = "select checkup_date from checkup_form where emp_id = '".$empid."' and checkup_type_id='25' and date_format(date(checkup_date),'%Y-%m-%d') between STR_TO_DATE('".$start."','%d-%m-%Y') and STR_TO_DATE('".$end."','%d-%m-%Y')";
error_log($sql);
$result = mysqli_query($conn,$sql);
$dates=array();
while ($row1 = mysqli_fetch_assoc($result)) {
$date=date_format(date_create($row1['checkup_date']), "Y-m-d");
array_push($dates,$date);
}
array_push($appints,$dates);
}
$examination_finded_arr =array_combine($emp_ids,$appints);
error_log('dates'.print_r($examination_finded_arr,true));
for($i=0;$i<count($emp_ids);$i++){
$empid=$emp_ids[$i];
error_log($i." ".$empid);
for($j=(count($appints[$i])-1);$j>=0;$j--){
if($j!=0){
$madExamStart=$examination_finded_arr[$empid][$j];
$madExamend= $examination_finded_arr[$empid][$j-1];
$sql_follow_up="select e.*,p.*,e.appointment_date as follow_up_date from employee_appointment e join patient_master p on e.emp_id=p.id where date_format(date(e.appointment_date),'%Y-%m-%d') between STR_TO_DATE('".$examination_finded_arr[$empid][$j]."','%Y-%m-%d') and STR_TO_DATE('".$examination_finded_arr[$empid][$j-1]."','%Y-%m-%d') and e.emp_id='".$empid."' and e.case_type='EFUP' ";
}else{
$madExamStart=$examination_finded_arr[$empid][$j];
$madExamend= $end;
$sql_follow_up="select e.*,p.*,e.appointment_date as follow_up_date from employee_appointment e join patient_master p on e.emp_id=p.id where date_format(date(e.appointment_date),'%Y-%m-%d') between STR_TO_DATE('".$examination_finded_arr[$empid][$j]."','%Y-%m-%d') and STR_TO_DATE('".$end."','%d-%m-%Y') and e.emp_id='".$empid."' and e.case_type='EFUP' "; }
error_log($empid.'follow-up_sql'.$sql_follow_up);
$result_sql_follow_up = mysqli_query($conn,$sql_follow_up);
// $num_rows = mysqli_num_rows($result_sqll);
while( $row_follow_up = mysqli_fetch_assoc($result_sql_follow_up)){
error_log($empid.'follow-up'.$row_follow_up['follow_up_date']);
?>
<strong>
<tr bgcolor="#eeeeee">
<td align="left" width="2%"><?=$count?></td>
<td align="left" width="5%"><?= $madExamStart." To ".$madExamend?></td>
<td align="left" width="4%"><?= $date=date_format(date_create($row_follow_up["follow_up_date"]), "Y-m-d")
?></td>
<td align="left" width="8%"><?= $row_follow_up['patient_name'] ?>
</td>
<td align="left" width="3%"><?=$row_follow_up['emp_code'] ?></td>
<td valign="top" align="left" width="5%">
<?= getTableFieldValue('designation','designation_name','designation_id',$row_follow_up['designation_id'] )?>
</td>
<td valign="top" align="left" width="4%">
<?= getTableFieldValue('bussiness_unit','bu_name','bu_id',$row_follow_up['bu_id'] )?></td>
<td valign="top" align="left" width="3%">
<?= getTableFieldValue('department','dept_name','dept_id',$row_follow_up['dept_id'] )?></td>
<td valign="top" align="left" width="3%">
<?= getTableFieldValue('section','section_name','section_id',$row_follow_up['section_id'] )?></td>
<td valign="top" align="left" width="5%">
<?= getTableFieldValue('sub_section','sub_section_name','sub_section_id',$row_follow_up['sub_section_id'] )?>
</td>
<td valign="top" align="left" width="4%"><?=$row_follow_up['primary_phone']?></td>
<td valign="top" align="left" width="4%">
<?php if($row_follow_up['case_type']=='EFUP') echo ' Executive Follow up'?></td>
<td valign="top" align="left" width="4%">
<?=$row_follow_up['complaints'] ?>
</td>
<td valign="top" align="left" width="5%">
<?= getCommaSeperatedValuesForInClause("select ailment_name from ailment ", "ailment_id", $row_follow_up['ailments_new'])?>
</td>
<td valign="top" align="left" width="5%">
<?= getTableFieldValue('ailment_system','ailment_sys_name','ailment_sys_id',$row_follow_up['ailment_systems_new'])?>
</td>
<td valign="top" align="left" width="2%"><?php if($row_follow_up['disease_type']=='COMM') {echo 'Communicable';}
else{echo 'Non-Communicable';}?></td>
<td valign="top" align="left" width="8%">
<?= getTreatmentText($row_follow_up['appointment_id'])?></td>
<td valign="top" align="left" width="3%"><?=$row_follow_up['health_advices_new']?></td>
<td valign="top" align="left" width="8%"><?=$row_follow_up['external_treatments']?></td>
<td valign="top" align="left" width="5%"><?=$row_follow_up['ecg_findings']?></td>
<td valign="top" align="left" width="5%"><?=$row_follow_up['recommended_tests_new']?></td>
<td valign="top" align="left" width="5%"><?=$row_follow_up['remarks']?></td>
<td valign="top" align="left" width="8%"><?=$row_follow_up['followup_remarks']?></td>
</tr>
<?php $count++; }
}
}
?>
<tr Height="10px">
<td colspan="10"><b>TOTAL: &nbsp;<?php echo $count-1 ?></b></td>
</tr>
</table>
</body>