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

813 lines
42 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!-- <button onclick="formSubmit()">GENEATE PDF</button> -->
<html>
<div id="htmltextthis">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<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;
}
</style>
<?php
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 name="checkup_form_employee" id="checkup_form_employee" method="POST">
<div id="preexam_form_div">
<table width="100%">
<?php include('new_pdf_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
echo getTableFieldValue('checkup_type', 'checkup_type_name', 'checkup_type_id', $row_p['checkup_type_id']);
?>
</b></u>
</span>
</div>
<div style="font-size:12px ;">
<span>
<u><b>PATIENT DETAILS</b></u>
<?php if($_GET['attachment'] != 'pdf') { ?>
<button align="center" id="printPageButton" class="btn btn-success" onClick="window.print();">Print</button>
<?php } ?>
</span>
</div>
<div class="panel-body">
<div class="row">
<?php
$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'];
error_log("section ids " . $checkup_section_ids);
$param_present = (explode(',', $row_p['checkup_section_ids']));
error_log("param present " . $param_present);
$param_present = array_unique($param_present);
error_log("unique param present " . $param_present);
// $param_present = '31,160,10,338,12,119';x
// $param_present = array(
// 31,
// 160,
// 10,
// 338,
// 12,
// 119
// );
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>
<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";
error_log("SQL SECTION ID : " . $sql_group_ids );
$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;"><u>
<?php if (($tital != '' || $tital != null) && ($param_value[$k] != 0 || $param_value[$k] != null || $param_value[$k] != '')) {
echo $tital;
} ?>
</u></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>
<?php
$Colors = getTableFieldValue('medical_examination_highlighted', 'highlighted_color', 'highlighted_fieils', "'" . $param_id[$k] . "'", 'medical_exam_id', $checkup_id);
if($Colors !=''){
$colorStyle = "color:".$Colors;
}?>
<td width="5%" style="font-size: 12px; <?php echo $colorStyle ?>">
<?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>
</tr>
<?php }
$k++;
$value--; ?>
<?php } ?>
<?php while ($value2 != 0) { ?>
<?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
}
?>
<?php
// echo $row_p['add_param_ids'];
if ($row_p['add_param_ids'] != "" && $row_p['add_param_ids'] != null) {
$units = 0;
$ranges = 0;
?>
<u>
<b
style="font-size: 15px; font-family: 'Source Sans Pro', 'Helvetica Neue',Helvetica, Arial, sans-serif;margin-top:10px">Additional/Other
Tests
</b>
</u>
<table width="100%"
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>
Unit
</b>
</td>
<td style="border-bottom:1px dashed #000000">
<b>
Ref Range
</b>
</td>
</tr>
<?php
$param_n = 0;
//query to load fields for additional Params
$sql_add_param = "select * from checkup_parameter a left join checkup_form_key_value b on a.column_name=b.checkup_form_key and b.checkup_form_id='" . $checkup_id . "' where a.checkup_parameter_id in (" . $row_p['add_param_ids'] . ") ";
error_log("additional param query " . $sql_add_param);
$result_add_param = mysqli_query($conn, $sql_add_param);
$param_n = mysqli_num_rows($result_add_param);
$param_name = array();
$param_id = array();
$param_ranges = array();
$param_value = array();
$param_unit = array();
$min = array();
$max = array();
while ($row_add_param = mysqli_fetch_assoc($result_add_param)) {
array_push($param_name, $row_add_param['parameter_name']);
array_push($param_id, $row_add_param['column_name']);
array_push($min, $row_add_param['starting_range']);
array_push($max, $row_add_param['ending_range']);
array_push($param_ranges, $row_add_param['ref_ranges']);
array_push($param_unit, getFieldFromTable('unit_name', 'checkup_parameter_unit_master', 'unit_id', $row_add_param['unit']));
if ($row_add_param['input_type'] == 'select') {
array_push($param_value, getFieldFromTable('parameter_value_name', 'checkup_parameter_value', 'parameter_value_id', $row_add_param['checkup_form_value']));
} else if ($row_add_param['input_type'] == 'multiselect') {
array_push($param_value, getCommaSeperatedValuesForInClause("select parameter_value_name from checkup_parameter_value", 'parameter_value_id', $row_add_param['checkup_form_value']));
} else {
array_push($param_value, $row_add_param['checkup_form_value']);
}
} ?>
<?php
for ($i = 0; $i < $param_n; $i++) {
?>
<tr>
<td width="25%" style="font-size: 12px;">
<b>
<?= $param_name[$i] ?>
</b>
</td>
<td width="5%"
style="word-wrap: break-word; word-break: break-all;font-size: 12px;color:
<?php echo getTableFieldValue('medical_examination_highlighted', 'highlighted_color', 'highlighted_fieils', "'" . $param_id[$i] . "'", 'medical_exam_id', $checkup_id) ?>">
<?php echo $param_value[$i] ?>
</td>
<td width="5%"
style="font-size: 12px;color: <?php echo getTableFieldValue('medical_examination_highlighted', 'highlighted_color', 'highlighted_fieils', "'" . $param_id[$i] . "'", 'medical_exam_id', $checkup_id) ?> ">
<span>
<?php
if ($param_unit[$i] != '' && $param_unit[$i] != null) {
$units++;
}
if (is_numeric($param_value[$i]) == 1) {
echo $param_unit[$i];
} else {
echo $param_unit[$i];
}
?>
</span>
</td>
<!-- <td width="25%" style="font-size:7px;">Ref Ranges</td> -->
<td width="30%" style="font-size: 12px;">
<span>
<?php
if ($param_ranges[$i] != '' && $param_ranges[$i] != null) {
$ranges++;
}
$rangs = explode('$', $param_ranges[$i]);
for ($r = 0; $r < count($rangs); $r++) {
if ($rangs != null && $rangs != '') {
echo '<p>' . $rangs[$r] . '</p>';
}
}
?>
</span>
</td>
</tr>
<?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 additional header loop -->
<span style="font-size:12px">
<center>
<u><b> FACTS AND FINDINGS</b></u>
</span>
<table width="100%" style="font-size:12px" border="1" cellspacing="0">
<?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.* 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; word-wrap: break-word; word-break: break-all;">
<?= ucwords(strtolower(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; word-wrap: break-word; word-break: break-all;">
<?= ucwords(strtolower(getCommaSeperatedValuesForInClause('select health_advice_name from health_advice', 'health_advice_id', $Facts['health_advice_id']))) ?>
</td>
</tr>
<br>
<tr>
<td style=" width:5%;font-size:10px">Chronic Illness :</td>
<td
style="width:5%; font-size: 10px; word-wrap: break-word; word-break: break-all;">
<?= ucwords(strtolower(implode(",", getChronicIllness($Facts['emp_id'])))); ?>
</td>
<td style="width:5%;font-size:10px">Habits :</td>
<td
style="width:5%;font-size: 10px;word-wrap: break-word; word-break: break-all;">
<?= ucwords(strtolower(getHabitData($Facts['emp_id']))); ?>
</td>
</tr>
</table>
<table border="0" width="100%" style="margin-top:5px">
<tr>
<td><img src="data:<?php echo $sign_row['image_type'] ?>;base64,<?php echo base64_encode($sign_row['emp_sign']) ?>" style="width: 120px; height: 80px;float: right" /></td>
</tr>
</table>
<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 getFieldFromTable('patient_name', 'patient_master', 'id', $Facts['doc_attend']) . " ," . $sign_row['qualification'];
?>
</span></td>
</tr>
</table>
<br>
<table width="100%">
<tr>
<td><span style="float: right;">KMC Reg No:
<?php echo $sign_row['registration_no'] ?>
</span>
</td>
</tr>
</table>
<br><br><br>
</div>
</div>
</div>
</div>
<!-- </table> -->
</form>
</body>
</div>
</html>
<?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 . "_" ."CHECKUP" ?>" />
<input type="hidden" name="param_value" id="param_value" value="<?php echo $checkup_id ?>" />
</form>
<script>
function formSubmit() {
$("#htmlText").val($("#htmltextthis").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);
$(document).ready(function(){
formSubmit();
});
</script>
<?php
}
?>