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

472 lines
22 KiB
PHP

<?php session_start();
include('includes/config/config.php');
include_once("includes/functions.php");
include_once("log_entry.php");
mysqli_query($conn, 'SET character_set_results=utf8');
error_reporting(0);
$query = "select * from company_profile where company_id = 5";
$result = mysqli_query($conn, $query);
$row_for_company = mysqli_fetch_array($result);
@extract($row_for_company);
?>
<!doctype html>
<html lang="en">
<head>
<title>REFERRAL LATTER</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<style>
u {
border-bottom: 1px dotted #000;
text-decoration: none;
}
.print {
position: absolute;
right: 11%;
}
@media print {
footer {
page-break-after: always;
}
#printPageButton {
display: none;
}
}
body {
font-family: Arial, Helvetica, sans-serif
}
table {
border-collapse: collapse;
}
.canteen {
background-color: #8E44AD;
/* position: relative; */
left: 20%;
text-align: center;
padding-left: 10%;
padding-right: 10%;
color: white;
}
</style>
</head>
<body>
<table>
<tr>
<td>
<div class="container">
<div class="container">
<div class="container">
<?php
include "pdf_ohc_header.php";
$query_emp = "select * from employee_appointment ep inner join patient_master p on p.id=ep.emp_id where ep.appointment_id='" . $_REQUEST['appointment_id'] . "' and ep.ohc_type_id='" . $_SESSION['current_ohcttype'] . "' ";
$result_emp = mysqli_query($conn, $query_emp);
$row = mysqli_fetch_assoc($result_emp);
?>
<button id="printPageButton" class="btn btn-success print" onClick="window.print();">Print</button>
<br>
<hr>
<br>
<h4 class="canteen">REFERRAL LETTER</h4>
<br>
<h5 align='right'>Date:
<?PHP echo "<u>" . date_format(date_create($row['appointment_date']), "d-M-Y") . "</u>&nbsp;&nbsp;&nbsp;" . "Time:" . "<u>" . date_format(date_create($row['appointment_date']), "H:i:s") . "</u>"; ?>
</h5>
<br>
<h5>Dear&nbsp;&nbsp;
<?PHP echo "<u>" . getTableFieldValue('referral_point', 'referral_point_name', 'referral_point_id', $row["referral"]) . "</u>"; ?>
</h5>
<br>
<h5>Referring Mr./Mrs/Miss :
<?PHP echo "<u>" . getTableFieldValue('patient_master', 'patient_name', 'id', $row['emp_id']) . "</u>&nbsp;&nbsp;&nbsp;"; ?>
Age : <u>
<?PHP $dob = getTableFieldValue('patient_master', 'dob', 'id', $row['emp_id']) . "</u>";
echo (date('Y') - date('Y', strtotime($dob)));
?>
</u> Yrs With
Complaints of : <u><?php $complaint_ids = $row['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];
}
}
}
echo $complaints;
?></u>
</h5>
<br>
<wrap>
<h5>On examination, he/she has :
<u><?= getCommaSeperatedValuesForInClause("select examination_finding from examination_findings ", "id", $row['examination_remarks']); ?></u>
</h5>
</wrap>
<br>
<h5>The investigations done show :
<u><?= getCommaSeperatedValuesForInClause("select ailment_name from ailment ", "ailment_id", $row['ailments_new']); ?></u>
</h5>
<br>
<h5>My Clinical impression is :
<u><?= getCommaSeperatedValuesForInClause("select ailment_name from ailment ", "ailment_id", $row['ailments_new']); ?></u>
</h5>
<br>
<h5><b>I have given the following treatment :-</b></h5>
<h5>new case</h5>
<table border="1">
<tr>
<td width="5%"><strong>Sr.no</td>
<td width="25%"> <strong>Medicine</td>
<td width="20%"><strong>Dose Frequency</td>
<td width="20%"> <strong>Timing</td>
<td width="20%"><strong> Admin Route</td>
<td width="20%"><strong> Duration</td>
</tr>
<?php
$treatment = "SELECT * FROM `treatment` tr INNER JOIN tbl_items it on tr.item_id = it.item_id INNER JOIN tbl_categories cat on it.cat = cat.cat_id where cat.cat_id IN (2 , 5 , 13 , 6 , 12 , 1 , 10) and tr.appointment_id='" . $row["appointment_id"] . "'";
error_log("treatment :" . $treatment);
$result_treatment = mysqli_query($conn, $treatment);
$count = 0;
while ($row_treatment = mysqli_fetch_assoc($result_treatment)) {
$count++;
$sqlGroup = "SELECT group_id , item_id from group_items where item_id = '" .$row_treatment["item_id"] . "'";
error_log($sqlGroup . " GRP");
$queryGroup = mysqli_query($conn , $sqlGroup);
$countGroup = mysqli_num_rows($queryGroup);
$fetchGroup = mysqli_fetch_assoc($queryGroup);
error_log($countGroup . " GRP COUNT");
if ($countGroup != 0) {
// $item_id_ = $fetchGroup['group_id'];
continue;
}
else
{
$item_id_ = $row_treatment["item_id"];
}
?>
<tr>
<td width="5%"><?= $count ?></td>
<td width="25%"> <?php
echo getTableFieldValue("tbl_items", "item_name", "item_id", $item_id_);
// getItemWithFormName()
?></td>
<td width="20%">
<?= getTableFieldValue("medicine_frequency", "medicine_frequency", "frequency_id", $row_treatment["frequency_id"]) ?>
</td>
<td width="20%">
<?= getTableFieldValue("medicine_timings", "medicine_timing", "timing_id", $row_treatment["timing_id"]) ?>
</td>
<td width="20%">
<?= getTableFieldValue('dosage_category', 'dosage_category', 'dosage_category_id', $row_treatment["dosage_category_id"]) ?>
</td>
<td width="20%">
<?= ($row_treatment["for_days"]) ?>
</td>
</tr>
<?php
}
?>
<?php
if ($row["followup_to_opd"] != 0) {
$treatment = "SELECT * FROM `treatment` tr INNER JOIN tbl_items it on tr.item_id = it.item_id INNER JOIN tbl_categories cat on it.cat = cat.cat_id where cat.cat_id IN (2 , 5 , 13 , 6 , 12 , 1 , 10) and tr.appointment_id='" . $row["followup_to_opd"] . "'";
error_log($treatment);
$result_treatment = mysqli_query($conn, $treatment);
while ($row_treatment = mysqli_fetch_assoc($result_treatment)) {
$count++;
$sqlGroup = "SELECT group_id , item_id from group_items where item_id = '" .$row_treatment["item_id"] . "'";
error_log($sqlGroup . " GRP");
$queryGroup = mysqli_query($conn , $sqlGroup);
$countGroup = mysqli_num_rows($queryGroup);
$fetchGroup = mysqli_fetch_assoc($queryGroup);
error_log($countGroup . " GRP COUNT");
if ($countGroup != 0) {
// $item_id_ = $fetchGroup['group_id'];
continue;
}
else
{
$item_id_ = $row_treatment["item_id"];
}
?>
<tr>
<td width="5%"><?= $count ?></td>
<td width="25%"> <?php
echo getTableFieldValue("tbl_items", "item_name", "item_id", $item_id_);
// getItemWithFormName($row_treatment["item_id"])
?></td>
<td width="20%">
<?= getTableFieldValue("medicine_frequency", "medicine_frequency", "frequency_id", $row_treatment["frequency_id"]) ?>
</td>
<td width="20%">
<?= getTableFieldValue("medicine_timings", "medicine_timing", "timing_id", $row_treatment["timing_id"]) ?>
</td>
<td width="20%">
<?= getTableFieldValue('dosage_category', 'dosage_category', 'dosage_category_id', $row_treatment["dosage_category_id"]) ?>
</td>
<td width="20%">
<?= ($row_treatment["for_days"]) ?>
</td>
</tr>
<?php
}
}
?>
</table>
<br><br>
<h5><b>He/She is referred to you for your expert opinion and advise. Kindly examine the
patient and advise/do the needful. Please inform me about the progress of the
patient.</b></h5>
<br><br>
<table width="100%">
<tr>
<td>
<h5 style="text-align: left;">
<b>
Thanking you,
</b>
</h5>
</td>
<td style="text-align: right;">
<h5 style="text-align: right;">
<b>
Yours sincerely,
</b>
</h5>
</td>
</tr>
</table>
<?php $query = "select e.emp_sign,e.image_type,p.patient_name from employee_signature e left join tbl_users b on e.emp_id = b.emp_id left join patient_master p on p.id = b.emp_id where b.user_id ='" . $row['doctor_last_attended'] . "'";
error_log("Signatures :" . $query);
$result1 = mysqli_query($conn, $query);
$sign_row = mysqli_fetch_array($result1);
extract($sign_row);
?>
<div class="row">
<div style="width: 50%;" class="leftailgn">
<!-- <span>(SIGNATURE OF PT.)</span> -->
</div>
<div style="width: 50%;" align="right">
<?php if (!empty($sign_row['emp_sign'])) { ?>
<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']) ?>">
<?php } ?>
</div>
</div>
<h5 class="row">
<div style="width: 50%;" class="leftailgn">
</div>
<div style="width: 50%;" align="right">
<b> <span> <?= $sign_row["patient_name"] ?></span></b>
</div>
</h5>
<div class="row">
<div style="width: 50%;" class="leftailgn">
<!-- <span>(SIGNATURE OF PT.)</span> -->
</div>
<div style="width: 50%;" align="right">
<span>(CMO.<?= $row_for_company['company_name'] ?>)</span>
</div>
</div>
<br><br><br>
<h5>P.S :</h5>
<br>
<h5>
<b>
He/She is allergic to
</b>
<u>
<?php
echo getCommaSeperatedValuesForInClause("select salt_name from salt_master ", "salt_id", $row['drug_allergy']);
$row["drug_allergy"] ?>
</u>
</h5>
<h5>
<b>
He/She is suffering from
</b>
<u>
<?php
$SqlAbnormality = "SELECT diseases from prescription_master where emp_id = '" . $row['emp_id'] . "' ";
$QueryAmb = mysqli_query($conn, $SqlAbnormality);
while ($fetchAmb = mysqli_fetch_assoc($QueryAmb)) {
echo getFieldFromTable('abnormality_name', 'abnormality', 'abnormality_id', $fetchAmb['diseases']) . " ,";
}
// echo getCommaSeperatedValuesForInClause("select abnormality_name from abnormality ", "abnormality_id", $row['abnormalitys']);
?>
</u>
</h5>
<h5>
<b>
for which he/she is taking
</b>
<u>
<?php
$sql_prescription_master = "SELECT * FROM `prescription_master` where emp_id = '" . $row['emp_id'] . "' order by diagnosis_date desc";
error_log("prescription_master: " . $sql_prescription_master);
if (!$result_prescription_master = @mysqli_query($conn, $sql_prescription_master)) {
exit(error_log(mysqli_error($conn)));
}
$illness = '';
if (mysqli_num_rows($result_prescription_master) > 0) {
while ($row_prescription_master = mysqli_fetch_assoc($result_prescription_master)) {
echo getTableFieldValue('tbl_items', 'item_name', 'item_id', $row_prescription_master['medicine_name']) . " ,";
}
}
$OtherMedicationsql = "SELECT medication FROM other_medication where emp_id = '" . $row['emp_id'] . "' order by id desc ";
$OtherMedicationQuery = mysqli_query($conn, $OtherMedicationsql);
if (mysqli_num_rows($OtherMedicationQuery) > 0) {
$fetchOtherMedication = mysqli_fetch_assoc($OtherMedicationQuery);
echo strtoupper( $fetchOtherMedication['medication'] );
}
?>
</u>
</h5>
</div>
<br>
</div>
</div>
</td>
</tr>
</table>
<!-- <div style="height: 100px;"></div> -->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous">
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous">
</script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous">
</script>
</body>
</html>