ESH/checkup_form_pdf.php

665 lines
31 KiB
PHP
Raw Permalink Normal View History

2024-10-23 18:28:06 +05:30
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<!-- <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;
}
}
b {
color: blue;
}
</style>
<style>
* {
font-family: sans-serif;
}
/* table,
tr,
td {
border: 1px solid gray !important;
} */
/* table {
border: black !important;
} */
/* .tbl1 {
border-collapse: collapse;
} */
/* th {
background-color: #e1e1e1;
font-size: 10px;
font-style: bold;
vertical-align: top;
}
td {
text-align: left;
font-size: 10px;
vertical-align: top;
padding: 8px !important;
}
/* tr {
border: 1px solid black;
} */
</style>
<?php
// include autoloader;
include('includes/config/config.php');
include('log_entry.php');
include_once("includes/functions.php");
$checkup_id = $_REQUEST['checkup_id'];
$unitMap = getKeyValueMap('unit_master', 'unit_id', 'unit_name');
$query = "select * from ohc_type where ohc_type_id = '" . $_SESSION['current_ohcttype'] . "'";
error_log("query: 27: " . $query);
// echo $query;
$result = mysqli_query($conn, $query);
$row_company = mysqli_fetch_array($result);
@extract($row_company);
//Code for loading the Check up Sections List for the given Checkup page case
$sql_patient = "select * from checkup_form where checkup_id = '$checkup_id'";
$result_p = mysqli_query($conn, $sql_patient);
$row_p = mysqli_fetch_array($result_p);
@extract($row_p);
$queryc = "select * from company_profile ";
$resultc = mysqli_query($conn, $queryc);
$row_company = mysqli_fetch_array($resultc);
@extract($row_company);
?>
</head>
<body>
<form id="employeeDetailsFormPdf" action="" method="POST">
<input type="hidden" name="htmlText" id="htmlText" />
</form>
<form name="checkup_form_employee" id="checkup_form_employee" method="POST">
<div id="preexam_form_div">
<table width="100%">
<?php include('pdf_ohc_header.php')?>
<span style="opacity: 0.5; font-size: 10px;">
<center style="width:100%;">
(TO BE EXAMINED AND SIGNED
BY
FACTORY MEDICAL OFFICER)</center>
</span>
<hr>
<hr>
<input type="hidden" id="checkup_section_ids" name="checkup_section_ids[]">
<div class="mainPanel">
<div class="panel-group" id="accordion">
<div class="panel panel-default">
<div class="panel-heading" id="panel-heading1">
<span>
<center>
<u><b><?php
$sql_param = "select a.*,b.* from checkup_parameter a left join checkup_form_key_value b on a.column_name = b.checkup_form_key where checkup_form_id = '$checkup_id' and checkup_form_section_id = '$val' order by column_order";
$result_param = mysqli_query($conn, $sql_param);
$header='PATHOLOGY LABORATORY';
while ($row_param = mysqli_fetch_assoc($result_param)) {
$param_type = (explode(',', $row_param['checkup_type_ids']));
$param_type = array_unique($param_type);
for($i=0;$i<count($param_type);$i++){
$tital=getTableFieldValue('checkup_type','checkup_type_code','checkup_type_id',$param_type[$i]);
if($tital!='LAB_TEST'){
$header=getTableFieldValue('checkup_type','checkup_type_name','checkup_type_id',$param_type[$i]);
}
}
}
echo $header;
?>
</b></u>
</span>
</div>
<div style="font-size:12px ;">
<span>
<u><b>PATIENT DETAILS</b></u><button align="center" id="printPageButton"
class="btn btn-success" onClick="window.print();">Print</button>
</span>
</div>
<div class="panel-body">
<div class="row">
<?php
// $emp_id ='5504';
$sql_employee = "select * from patient_master where id=(select emp_id from checkup_form where checkup_id='$checkup_id' )";
$result = mysqli_query($conn, $sql_employee);
//$checkup_id = $_REQUEST['flex_checkup_id'];
// $sql_checkup = "select * from checkup_form where checkup_id='$checkup_id'";
//echo $sql_checkup;
$checkup_result = mysqli_query($conn, $sql_employee);
$row_checkup = mysqli_fetch_assoc($checkup_result);
while ($row_employee = mysqli_fetch_assoc($result)) {
$patient = $row_employee['patient_name'];
$gender = $row_employee['gender'] == 'm' || $row_employee['gender'] == 'M' ? 'MALE' : 'FEMALE';
$age = "";
if (!empty($row_employee['dob'])) {
$dob = $row_employee['dob'];
$age = (date('Y') - date('Y', strtotime($dob)));
}
?>
<table border="0" width="100%" style="margin-bottom:5px">
<tr>
<td width="33%" style="font-size:12px;">
<b>Date:</b>
<?php echo date_format(date_create($row_p['checkup_date']), "d-M-Y") ?>
</td>
<td width="33%" style="font-size:12px;">
<b>PME No.</b>
<?php echo $row_p['ticket_no'] ?>
</td>
<td style="font-size:12px;">
<b>DOJ:</b>
<?php if(!empty($row_employee['doj'])) echo date_format(date_create($row_employee['doj']), "d-M-Y") ?>
</td>
</tr>
<tr>
<td width="33%" style="font-size:12px;">
<b>DESIGNATION:</b>
<?php echo getFieldFromTable('designation_name', 'designation', 'designation_id', $row_employee['designation_id']) ?>
</td>
<td width="33%" style="font-size:12px;">
<b>DEPARTMENT:</b>
<?php echo getFieldFromTable('dept_name', 'department', 'dept_id', $row_employee['dept_id']) ?>
</td>
<td style="font-size:12px;">
<b>DIVISION:</b>
<?php echo getTableFieldValue('bussiness_unit', 'bu_name', 'bu_id', $row_employee['bu_id'], ''); ?>
</td>
</tr>
<tr>
<td width="33%" style="font-size:12px;">
<b>TRADE</b>
<?php echo $row_employee['doj'] ?>
</td>
<td width="33%" colspan="2" style="font-size:12px;">
<b>EMPLOYEE ID</b>
<?php echo $row_employee['emp_code'] ?>
</td>
</tr>
<tr>
<td width="33%" style="font-size:12px;">
<b>NAME OF CANDIDATE:</b>
<?php echo $row_employee['patient_name'] ?>
</td>
<td width="33%" style="font-size:12px;">
<b>DOB:</b>
<?= !empty($row_employee['dob']) ? date_format(date_create($row_employee['dob']), "d-M-Y") : '' ?>
</td>
<td style="font-size:12px;">
<b>AGE</b>
<?php echo $age ?>
</td>
</tr>
<tr>
<td width="42%" style="font-size:12px;">
<b>FATHERS/HUSBANDS NAME:</b>
<?php echo $row_employee['father_name'] ?>
</td>
<td width="33%" style="font-size:12px;">
<b>GENDER:</b>
<?php echo $row_employee['gender'] == 'm' || $row_employee['gender'] == 'M' ? 'MALE' : 'FEMALE' ?>
</td>
<td style="font-size:12px;">
<b>BLOOD GROUP: </b>
<?= $row_employee['blood_group'] ?>
</td>
</tr>
<?php } ?>
</table>
<hr>
<?php
$checkup_section_ids = $row_p['checkup_section_ids'];
$param_present = (explode(',', $row_p['checkup_section_ids']));
$param_present = array_unique($param_present);
foreach ($param_present as $x => $val) {
$units=0;
$ranges=0;
$notes='';
$comments='';
$notes .= getTableFieldValue( 'checkup_form_section','notes', 'section_id', $val);
$comments.=(getTableFieldValue( 'checkup_form_section','comments', 'section_id',
$val));
?>
<u><b height='' class="section<?= $val?>"
style="font-size: 15px; font-family: 'Source Sans Pro', 'Helvetica Neue',Helvetica, Arial, sans-serif;margin-top:10px">
<?php $test_name=getFieldFromTable('section_name', 'checkup_form_section', 'section_id', $val);
echo $test_name;
?>
</b></u>
</div>
<table width="100%" class='section<?= $val?>'
style="margin-top: 10px;border-top:solid 1px ;border-bottom:solid 1px">
<tr>
<td style="border-bottom:1px dashed #000000">
<b> Test Names </b>
</td>
<td style="border-bottom:1px dashed #000000">
<b>Result</b>
</td>
<td style="border-bottom:1px dashed #000000"><b class="unit<?=$val?>">
Unit</b>
</td>
<td style="border-bottom:1px dashed #000000"><b class="range<?=$val?>">
Ref Range</b>
</td>
</tr>
<?php
$param_n=0;
//query to load fields for each section
$sql_param = "select a.*,b.* from checkup_parameter a left join checkup_form_key_value b on a.column_name = b.checkup_form_key where checkup_form_id = '$checkup_id' and checkup_form_section_id = '$val' order by column_order";
error_log("//query to load fields for each section@@@@@@@!!!!" . $sql_param);
$result_param = mysqli_query($conn, $sql_param);
$param_name = array();
$param_id = array();
$param_ranges = array();
$param_value = array();
$param_unit = array();
$min= array();
$max= array();
while ($row_param = mysqli_fetch_assoc($result_param)) {
array_push($param_name, $row_param['parameter_name']);
array_push($param_id, $row_param['column_name']);
array_push($min, $row_param['starting_range']);
array_push($max, $row_param['ending_range']);
array_push($param_ranges, $row_param['ref_ranges']);
array_push($param_unit, getFieldFromTable('unit_name', 'checkup_parameter_unit_master', 'unit_id', $row_param['unit']));
if ($row_param['input_type'] == 'select') {
array_push($param_value, getFieldFromTable('parameter_value_name', 'checkup_parameter_value', 'parameter_value_id', $row_param['checkup_form_value']));
} else if ($row_param['input_type'] == 'multiselect') {
array_push($param_value, getCommaSeperatedValuesForInClause("select parameter_value_name from checkup_parameter_value", 'parameter_value_id', $row_param['checkup_form_value']));
} else {
array_push($param_value, $row_param['checkup_form_value']);
}
} ?>
<?php
$sql_group_ids = "select count(distinct(a.group_id)) as field_value from checkup_parameter a left join checkup_form_key_value b on a.column_name = b.checkup_form_key where checkup_form_id = '$checkup_id' and checkup_form_section_id = '$val' order by column_order";
$result_grp = mysqli_query($conn, $sql_group_ids);
$row_grp = mysqli_fetch_assoc($result_grp);
$total_group_ids = $row_grp['field_value'];
//echo 'hellooooooooooooooooooo';
error_log("total group ids:" . $total_group_ids);
$group_ids = array();
for ($i = 1; $i <= $total_group_ids; $i++) {
$group_id = "select count(group_id) from checkup_parameter where group_id = '$i' and enabled!='N' and checkup_form_section_id = '$val'";
error_log("group id len query:" . $group_id);
$result_group_id = mysqli_query($conn, $group_id);
$row_group_id = mysqli_fetch_array($result_group_id);
array_push($group_ids, $row_group_id['0']);
}
$max_len = max($group_ids);
error_log("max len :" . $max_len);
error_log(" group ids : " . print_r($group_ids, true));
$k = 0;
for ($i = 0; $i < $total_group_ids; $i++) {
$grp=$i+1;
$tital=getTableFieldValue('checkup_parameter_group','group_tital','group_section',$val,'group_no',$grp);
if(($tital!='' || $tital!=null )&&($param_value[$k]!=0 || $param_value[$k]!=null || $param_value[$k]!='' )) {
?>
<tr>
<td colspan="<?=$rows_no_groups[$h]?>">
<b
style=" font-size: 12px; font-weight: 600;"><?php if(($tital!='' || $tital!=null )&&($param_value[$k]!=0 || $param_value[$k]!=null || $param_value[$k]!='' )) { echo $tital;}?></b>
</td>
</tr>
<?php }?>
<?php $value = $group_ids[$i];
$value2 = $max_len - $value;
while ($value != 0) {
if( $param_value[$k]!=null && $param_value[$k]!='' ){
$param_n++;
?>
<tr>
<td width="25%" style="font-size: 12px;">
<b><?= $param_name[$k] ?></b>
</td>
<td width="5%"
style="font-size: 12px;color:
<?php echo getTableFieldValue('medical_examination_highlighted','highlighted_color','highlighted_fieils',"'".$param_id[$k]."'",'medical_exam_id',$checkup_id)?>">
<?php echo $param_value[$k] ?>
</td>
<td width="5%"
style="font-size: 12px;color: <?php echo getTableFieldValue('medical_examination_highlighted','highlighted_color','highlighted_fieils',"'".$param_id[$k]."'",'medical_exam_id',$checkup_id)?> ">
<span class="unit<?=$val?>"> <?php
if($param_unit[$k]!='' && $param_unit[$k]!=null){
$units++;
}
if(is_numeric($param_value[$k])==1){
echo $param_unit[$k];
}else{
echo $param_unit[$k];
}
?>
</span>
</td>
<!-- <td width="25%" style="font-size:7px;">Ref Ranges</td> -->
<td width="30%" style="font-size: 12px;">
<span class="range<?=$val?>">
<?php
if($param_ranges[$k]!='' && $param_ranges[$k]!=null){
$ranges++;
}
$rangs=explode('$', $param_ranges[$k]);
for($r=0;$r<count($rangs);$r++){
if($rangs!=null && $rangs!=''){
echo '<p>'.$rangs[$r].'</p>';}
}
?>
</span>
</td>
<?php }
$k++;
$value--; ?>
<?php } ?>
<?php while ($value2 != 0) { ?>
<!-- <td width="6%" style="font-size: 12px;">&nbsp;</td>
<td width="6%" style="font-size: 12px;">&nbsp;</td>
<td width="6%" style="font-size: 12px;">&nbsp;</td>
<td width="6%" style="font-size: 12px;">&nbsp;</td>
<td width="6%" style="font-size: 12px;">&nbsp;</td>
<td width="6%" style="font-size: 12px;">&nbsp;</td> -->
</tr>
<?php
$value2--; ?>
<?php } ?>
<?php }?>
</table>
<script>
<?php if($ranges==0) {?>
$('.range' + <?=$val?>).hide();
<?php } ?>
<?php if($units==0) {?>
$('.unit' + <?=$val?>).hide();
<?php } ?>
<?php if($param_n==0) {?>
$('.section' + <?=$val?>).hide();
<?php } ?>
</script>
<?php
}
//end of foreach - section header loop
?>
<span style="font-size:12px">
<center>
<u><b> FACTS AND FINDINGS</b></u>
</span>
<table width="100%" style="font-size:12px">
<?php $checkup_id = $_REQUEST['checkup_id'];
$query = "select * from checkup_form where checkup_id=$checkup_id";
error_log("Facts :" . $query);
$result = mysqli_query($conn, $query);
$Facts = mysqli_fetch_array($result);
// if($_SESSION['RoleCode'] == $__ROLE_DOCTOR){
// $roleCode = $_SESSION['RoleCode'];
// }else{
// $roleCode = $_SESSION['RoleCode'];
// }
$query = "select e.emp_sign,e.image_type from employee_signature e left join checkup_form b on e.emp_id = b.doc_attend where b.checkup_id ='" . $checkup_id . "'";
// error_log("Signatures :" . $query);
$result1 = mysqli_query($conn, $query);
$sign_row = mysqli_fetch_array($result1);
extract($sign_row);
?>
<!-- <tr >LAB TECHNICIAN's</tr> -->
<!--
<tr>
<td style="width:5%; height:50px;">Lab Technician Findings</th>
<td style="width:15% height:50px;"> <?= $Facts['comments'] ?></td>
<td style="width:5%; height:50px;">Lab Technician Comments</th>
<td style="width:15%; height:50px;"><?= $Facts['findings'] ?></td>
</tr>-->
<br>
<tr>
<td style="width:5%;;font-size:10px">Doctor's Findings</td>
<td style="width:15%;font-size: 10px;"><?= $Facts['doc_findings'] ?></td>
<td style=" width:5%;;font-size:10px">Doctor's Comments</td>
<td style="width:15%;font-size: 10px;"><?= $Facts['doc_comments'] ?></td>
</tr>
<br>
<tr>
<td style=" width:5%;font-size:10px">Health Risks :</td>
<td style="width:5%; font-size: 10px;">
<?=getCommaSeperatedValuesForInClause('select health_risk_name from health_risk','health_risk_id',$Facts['health_risk_id'])?>
</td>
<td style="width:5%;font-size:10px">Health Advices :</td>
<td style="width:5%;font-size: 10px;">
<?=getCommaSeperatedValuesForInClause('select health_advice_name from health_advice','health_advice_id',$Facts['health_advice_id'])?>
</td>
</tr>
</table>
<hr>
<span style="font-size:12px;margin-top:10px">
<center>
<u><b>MEDICAL FITNESS
CERTIFICATE</b></u>
</span>
<table border="0" width="100%" style="margin-top:5px">
<tr>
<td>
&nbsp;
</td>
</tr>
<?php if ($row_p['fit_unfit_status'] == 'fit') {
$fit_status = "FIT";
} else if ($row_p['fit_unfit_status'] == 'pfit') {
$fit_status = "PROVISIONAL FIT";
} else if ($row_p['fit_unfit_status'] == 'tfit') {
$fit_status = "TEMPORARY UNFIT";
} else {
$fit_status = "UNFIT";
}
?>
<tr>
<td colspan="2">
<p style="font-size: 12px;width:100%;margin-left:2%">
I HERE BY CERTIFY THAT, I HAVE PERSONALLY EXAMINED
MR/MS/MRS <u><?= $patient ?></u><br><br> DATE OF BIRTH <u>
<?php echo !empty($dob) ? date_format(date_create($dob), "d-M-Y") : '' ?></u>,
GENDER <u><?php echo $gender ?></u>, AND BASED ON THE INVESTIGATIONS &
MEDICAL EXAMINATION HE/SHE IS :- <?= $fit_status ?>
</p>
</td>
</tr>
<tr>
<td style="width: 50%;"></td>
<td style="width: 50%;" align="right"><img id='sign'
style="text-align:center; width:150px; height:80px;"
class="card-img-bottm"
src="data:<?= $sign_row['image_type']; ?>;base64,<?= base64_encode($sign_row['emp_sign']) ?>"><br>
</td>
</tr>
</table>
</div>
</div>
<!-- </table> -->
</form>
</body>
<script>
// $(document).ready(function() {
// formSubmit();
// });
// $("td").each(function() {
// if (this.innerText === '') {
// this.closest('tr').remove();
// }
// });
function formSubmit() {
$("#htmlText").val($("#checkup_form_employee").html());
document.forms['employeeDetailsFormPdf'].action = "pdf_dynamic.php";
document.forms['employeeDetailsFormPdf'].method = "post";
document.forms['employeeDetailsFormPdf'].submit();
}
</script>
<script>
// $(document).ready(function() {
// window.print();
// });
</script>