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

217 lines
7.1 KiB
PHP

<?php //include('pdf_header_reverse.php');
include('includes/config/config.php');
include('includes/functions.php');
//include('pop_up_top.php');
$emp_id = $_REQUEST['patient_id'];
$id = $_REQUEST['patient_id'];
$parameters = $_REQUEST['health_parameter'];
$start = date('d-m-Y', strtotime($_POST['opdDate1']));
$end = date('d-m-Y', strtotime($_POST['opdDate2']));
$from_date1 = date('Y-m-d', strtotime($_POST['opdDate1']));
$from_date = date('d-m-Y', strtotime($from_date1));
$from_date2 = date('Y-m-d', strtotime($_POST['opdDate2']));
$to_date = date('d-m-Y', strtotime($from_date2));
$all = $_POST['all1'];
$startDate=$from_date;
$endDate=$to_date;
$checkup_id = array();
// $checkup_parameter_ids = array();
$checkup_parameter_values = array();
$checkup_param_range=array();
$status_data = array();
$date_count = array();
$emp_id_arr=array();
$param_date=array();
if($all==1){
$emp_fiter=" " ;
}else{
$emp_fiter=" and b.emp_id='$id' " ;
}
$result_checkup_form = @mysqli_query($conn, $checkup_form);
$query = "SELECT a.column_name,b.key_param_name,a.checkup_parameter_id,a.ref_ranges FROM `checkup_parameter` a left join key_health_reportable_parameter_master b on a.key_health_map_name=b.key_param_id WHERE a.key_health_map_name='".$parameters."' ";
// error_log($query);
$result = @mysqli_query($conn, $query);
if (mysqli_num_rows($result) > 0) {
while ($row = @mysqli_fetch_array($result)) {
$checkup_form_key_value="select a.checkup_form_id,a.checkup_form_value,b.checkup_type_id,a.checkup_form_key from checkup_form_key_value a left join checkup_form b on a.checkup_form_id=b.checkup_id where a.checkup_form_key='".$row["column_name"]."' and date(b.checkup_date) between STR_TO_DATE('" . $startDate . "', '%d-%m-%Y') AND STR_TO_DATE('" . $endDate . "', '%d-%m-%Y') and b.ohc_type_id='" . $_SESSION['current_ohcttype'] . "' ".$emp_fiter;
// error_log("checkup_form_key_value:chart".$checkup_form_key_value);
$result_checkup_form_key_value = @mysqli_query($conn, $checkup_form_key_value);
if (mysqli_num_rows($result_checkup_form_key_value) > 0) {
while($row_value=@mysqli_fetch_array($result_checkup_form_key_value)){
//push dates in an array
if(($row_value["checkup_form_value"]!='' ||$row_value["checkup_form_value"]!=null) && !in_array($row_value["checkup_form_id"], $checkup_id) ){
$checkup_parameter_values+=array($row_value['checkup_form_id']=>$row_value["checkup_form_value"]);
// $checkup_parameter_ids+=array($row_value['checkup_form_id']=>$row['checkup_parameter_id']);
$checkup_param_range+=array($row_value['checkup_form_id']=>$row['ref_ranges']);
array_push($checkup_id,$row_value["checkup_form_id"]);
}
}}
}
}
// $param_id =$checkup_parameter_ids;
$param_range =$checkup_param_range;
$param_value =$checkup_parameter_values;
// echo print_r($param_id,true).'<br>';
// echo print_r($checkup_id,true);
// echo print_r($param_value,true);
?>
<link href="includes/css-js/admin.css" rel="stylesheet" type="text/css" />
<style>
@page {
margin: 15px;
}
table ,tr, td{
font-size:12px;
}
.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></td>
<td style="font-size: 15px;" align="center"><strong>Patient Medical Parameter Report
</strong></td>
<td></td>
</tr>
<tr>
<td align=" center" width="20%" style="font-size: 13px;padding-top: 10px;">
<strong>For <?php if($all==1){ echo 'ALL';}
?> Patient <?php if($all!=1){ echo ':'.getTableFieldValue('patient_master', 'patient_name', 'id', $id) ;} ?></strong>
</td>
<td align=" center" style="font-size: 13px;padding-top: 10px;color:red"><strong>(Medical parameter:
<?=getTableFieldValue('key_health_reportable_parameter_master', 'key_param_name', 'key_param_id',$parameters) ?>)</strong>
</td>
<td align=" center" width="20%" style="font-size: 13px;padding-top: 10px;"><strong>(From
<?= date('d-M-Y',strtotime($startDate))?> to <?= date('d-M-Y',strtotime($endDate))?>)</strong>
</td>
</tr>
<tr>
<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">
<strong>
<tr bgcolor="#eeeeee">
<td align="left" width="2%">Sr.</td>
<td align="left" width="3%">Employee No.</td>
<td align="left" width="3%">Employee Name</td>
<td align="left" width="3%">Gender</td>
<td align="left" width="3%">Location</td>
<td align="left" width="3%">Department</td>
<td align="left" width="3%">Exam Date</td>
<td align="left" width="3%">Test recorded</td>
<td align="left" width="3%">Test Normal Value</td>
<td align="left" width="3%">Phone No.</td>
</tr>
<?php
$count=0;
foreach($checkup_id as $key=>$checkup){
$emp_data="select emp_code,gender ,patient_name,dept_name,primary_phone,date_format(date(checkup_date),'%d-%m-%Y') as date,b.ohc_type_id from view_patient_master a left join checkup_form b on a.id=b.emp_id where checkup_id='".$checkup."'";
error_log($emp_data);
$result_emp_data = @mysqli_query($conn, $emp_data);
while ($row_emp_data = @mysqli_fetch_array($result_emp_data)) {
$count++
?>
<tr>
<td><?=$count;?></td>
<td><?=$row_emp_data['emp_code'];?></td>
<td><?=$row_emp_data['patient_name'];?></td>
<td><?php if($row_emp_data['gender']=='M')echo 'Male';
else if($row_emp_data['gender']=='F')echo 'Female';
?></td>
<td><?=getTableFieldValue('ohc_type','ohc_type_name','ohc_type_id',$row_emp_data['ohc_type_id']);?></td>
<td><?=$row_emp_data['dept_name'];?></td>
<td><?=$row_emp_data['date'];?></td>
<td><?=$param_value[$checkup];?></td>
<td><?=$param_range[$checkup];?></td>
<td><?=$row_emp_data['primary_phone'];?></td>
</tr>
<?php } }?>
</table>
</body>
<script>
// $(document).ready(function() {
// window.print();
// });
</script>