<html>



<head>

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
    <div id="opd_form_div" style="display: none">
        <form id="opd_form" name="opd_form">

            <?php

            // include autoloader;
            include('includes/config/config.php');
            include('log_entry.php');
            include_once("includes/functions.php");

            $appoint_id = $_REQUEST['appointment_id_pdf'];
            if ($appoint_id == '' || $appoint_id == null) {
                $appoint_id = $_REQUEST['appointment_idpdf'];
            }
            error_reporting(E_ERROR | E_PARSE);
            error_log("error" . $appoint_id);
            $unitMap = getKeyValueMap('unit_master', 'unit_id', 'unit_name');

            $queryc = "select * from company_profile ";

            // echo $query;

            error_log("APPOINTMENT ID PDF::" . $$appoint_id);

            $resultc = mysqli_query($conn, $queryc);

            $row_company = mysqli_fetch_array($resultc);

            @extract($row_company);

            $sql_employee_appointment = "select a.*, p.patient_name, p.dept_id, p.emp_code, p.father_name, p.designation_id,employer_contractor_id,
patient_cat_id, gender,blood_group,emp_cadre,dob,p.dept_id,p.bu_id,p.section_id,p.bu_id,p.sub_section_id from employee_appointment a, patient_master p where a.emp_id=p.id
 and appointment_id='" . $appoint_id . "'";
            error_log("error" . $sql_employee_appointment);
            // echo $sql_employee_appointment;

            error_log("OPD PDF QUERY:" . $sql_employee_appointment);

            $res_emp_appoint = mysqli_query($conn, $sql_employee_appointment);

            $rows_emp_appoint = mysqli_fetch_array($res_emp_appoint);

            @extract($rows_emp_appoint);

            $patient_name = $rows_emp_appoint['patient_name'];
            $followup_id = $rows_emp_appoint['followup_id'];
            if ($followup_id == '' || $followup_id == null) {
                $followup_id = 0;
            }
            // echo $query;
            $attended_doc = $rows_emp_appoint['doctor_last_attended'];
            $doc_user_id = ($attended_doc != null && $attended_doc != 0 && $attended_doc != "") ? $attended_doc : $rows_emp_appoint['modified_by'];

            $doc_emp_id = getTableFieldValue('tbl_users', 'emp_id', 'user_id', $doc_user_id, '');

            error_log($doc_emp_id);

            $doc_name = getTableFieldValue('patient_master', 'patient_name', 'id', $doc_emp_id, '');



            $result = mysqli_query($conn, $query);

            $row = mysqli_fetch_array($result);

            @extract($row);

            $sql_doc_details = "select * from employee_signature where emp_id='$doc_emp_id'";

            $result_doc_details = mysqli_query($conn, $sql_doc_details);
            $row_doc_details = mysqli_fetch_array($result_doc_details);

            $employee_code = $rows_emp_appoint['emp_code'];

            $father_name = $rows_emp_appoint['father_name'];

            if ($rows_emp_appoint['IsEmergency'] == 1) {

                $ans = "Yes";
            } else {

                $ans = "No";
            }

            date_default_timezone_set('Asia/Kolkata');
            $date = date('Y-m-d H:i:s');
            $currentDate = date_format(date_create($date), "d-M-Y h:i:sa  ");
            $ailment_names = $rows_emp_appoint['ailments_new'];
            $health_advices = $rows_emp_appoint['health_advices_new']; // getCommaSeperatedValuesForInClause("select health_advice_name from health_advice ","health_advice_id",$rows_emp_appoint['health_advices']);
            $tests = $rows_emp_appoint['recommended_tests_new']; // getCommaSeperatedValuesForInClause("select section_name from checkup_form_section ","section_id",$rows_emp_appoint['tests']);

            ?>



            <style>
                th {

                    font-size: 12px;
                    font-style: bold;
                    vertical-align: top;
                }

                td {
                    text-align: left;
                    font-size: 11px;
                    vertical-align: top;
                }
            </style>

</head>

<!-- <div
	style="font-size: 12px; float: right;border: 1px solid black;padding: 5px">

<b>F-MED-01</b>
 	
</div> -->

<table width="100%">
    <tr>

        <td width="40%">
            <?php if (isset($row_company['company_logo']) && $row_company['company_logo'] != null) { ?>
                <img src="data:<?php echo $row_company['image_type'] ?>;base64,<?php echo base64_encode($row_company['company_logo']) ?>" style="width: 150px; height: 60px; margin: 0px; padding: 0px;">
            <?php } ?>
        </td>

        <td width="60%" align="center">
            <div style="margin-left: 20px;">
                <center style="font-size: 15px ;"><b>
                        <?php echo $row_company['company_name'] ?>
                        <br> <span style="font-size: 12px; ;">MEDICAL DEPARTMENT</span>
                        <pre style="margin-top: 0px; font-size:10px;"><?php echo $row_company['address'] ?></pre>
                    </b>
                </center>
            </div>
        </td>
        <td width="40%" align="right">
            <?php if (isset($row_company['right_com_logo']) && $row_company['right_com_logo'] != null) { ?>
                <img src="data:<?php echo $row_company['right_image_type'] ?>;base64,<?php echo base64_encode($row_company['right_com_logo']) ?>" style="width: 150px; height: 60px; margin: 0px; padding: 0px;">

            <?php } ?>
        </td>
    </tr>



    <tr rowspan="2">
        <td colspan="1"></td>
        <td colspan="2"></td>
    </tr>



    <tr>
        <td colspan="1"></td>
        <td colspan="2"></td>
    </tr>
    <tr>
        <td colspan="1"></td>
        <td colspan="2"></td>
    </tr>

    <tr>
        <td colspan="1"></td>
        <td colspan="2"><strong style="margin-left: 110px;text-decoration: underline;">PRESCRIPTION</strong></td>
    </tr>
</table>

<!-- <div style="display: inline-block;">
	<h3><?php echo $row_company['company_name'] ?></h3>
	<strong style="float: right;">Mob.<?php echo $row_company['primary_phone'] ?></strong>
</div>
<div style="margin-top: -50px;">
	<h5 style="text-align: center"><?php echo $row_company['address'] ?></h5>
</div>
<div>
	<h5 style="text-align: center;text-decoration: underline;">OPD TICKET</h5>
</div> -->


<!--  -->

<br>


<table style="border: 1px solid black;font-size: 11px" width="100%">





    <tr>

        <td><strong>MRN:</strong><?php echo  $rows_emp_appoint['ticket_no'] ?></td>

        <td width="50%"><b>EMPLOYEE ID:</b> <?php echo $employee_code ?></td>




    </tr>







    <tr>
        <td width="50%"><b>PATIENT NAME:</b> <?php echo $patient_name ?> </td>


        <td width="50%"><b>FATHER'S NAME:</b> <?php echo $father_name ?></td>



    </tr>

    <tr>

        <td width="50%"><b>AGE:</b>
            <?php echo isset($rows_emp_appoint['dob']) ? date_diff(date_create($rows_emp_appoint['dob']), date_create('today'))->y : "Not Available"; ?>
        </td>

        <td width="50%"><b>GENDER:</b> <?php echo $rows_emp_appoint['gender'] == 'M' ? "Male" : "Female" ?></td>


    </tr>



    <tr>



        <td width="50%"><b>DIVISION:</b>
            <?php echo getTableFieldValue('bussiness_unit', 'bu_name', 'bu_id', $rows_emp_appoint['bu_id'], ''); ?></td>

        <td width="50%"><b>DEPARTMENT:</b>
            <?php echo getTableFieldValue('department', 'dept_name', 'dept_id', $rows_emp_appoint['dept_id'], ''); ?>
        </td>



    </tr>

    <tr>

        <!-- <td width="50%">
            <b>UTE: </b>
            <?php echo getTableFieldValue('section', 'section_name', 'section_id', $rows_emp_appoint['section_id'], ''); ?>
        </td> -->

        <td width="50%">
            <b>AREA/SECTION:</b>
            <?php echo getTableFieldValue('sub_section', 'sub_section_name', 'sub_section_id', $rows_emp_appoint['sub_section_id'], ''); ?>
        </td>

    </tr>






    <tr>



        <td width="50%"><b>IN TIME:</b>
            <?php echo date_format(date_create($rows_emp_appoint['appointment_date']), "d-M-Y h:i:sa  ") ?></td>

        <td width="50%"><b>CLEARANCE TIME:</b>
            <?php echo date_format(date_create($rows_emp_appoint['clearance_time']), "d-M-Y h:i:sa  ") ?></td>

    </tr>




</table>



<br>

<?php if ($rows_emp_appoint['weight'] != 0 && $rows_emp_appoint['weight'] != '') { ?>
    <div style="width: 10%; display: inline; font-size: 12px; text-transform: capitalize;">
        <b>Weight:</b> <?php echo $rows_emp_appoint['weight'] ?> kg
    </div>
<?php } ?>

<?php if ($rows_emp_appoint['height'] != 0 && $rows_emp_appoint['height'] != '') { ?>
    <div style="width: 15%; display: inline; font-size: 12px ; text-transform: capitalize;">
        <b>Height:</b> <?php echo $rows_emp_appoint['height'] ?> cm
    </div>
<?php } ?>

<?php if ($rows_emp_appoint['bmi'] != 0 && $rows_emp_appoint['bmi'] != '') { ?>
    <div style="width: 15%; display: inline; font-size: 12px; text-transform: capitalize;">
        <b>BMI:</b> <?php echo $rows_emp_appoint['bmi'] ?>
    </div>
<?php } ?>

<?php if (($rows_emp_appoint['bp_sbp'] != 0 || $rows_emp_appoint['bp_sbp'] != '') && ($rows_emp_appoint['bp_dbp'] != 0 || $rows_emp_appoint['bp_dbp'] != '')) { ?>
    <div style="width: 10%; display: inline; font-size: 12px;">
        <b>BP:</b> <?php echo $rows_emp_appoint['bp_sbp'] ?>/<?php echo $rows_emp_appoint['bp_dbp'] ?> mmhg
    </div>
<?php } ?>

<?php if ($rows_emp_appoint['heart_rate'] != 0 && $rows_emp_appoint['heart_rate'] != '') { ?>
    <div style="width: 15%; display: inline; font-size: 12px; text-transform: capitalize;">
        <b>Pulse:</b> <?php echo $rows_emp_appoint['heart_rate'] ?>min
    </div>
<?php } ?>

<?php if ($rows_emp_appoint['temperature'] != 0 || $rows_emp_appoint['temperature'] != '') { ?>
    <div style="width: 15%; display: inline; font-size: 12px; text-transform: capitalize;">
        <b>Temp:</b> <?php echo $rows_emp_appoint['temperature'] ?>C
    </div>
<?php } ?>

<?php if ($rows_emp_appoint['spo2_percent'] != 0 || $rows_emp_appoint['spo2_percent'] != '') { ?>
    <div style="width: 15%; display: inline; font-size: 12px; text-transform: capitalize; ">
        <b>SPO2%:</b> <?php echo $rows_emp_appoint['spo2_percent'] ?>%
    </div>
<?php } ?>

<?php if ($rows_emp_appoint['blood_sugar_rbs'] != 0 || $rows_emp_appoint['blood_sugar_rbs'] != '') { ?>
    <div style="width: 15%; display: inline; font-size: 12px;">
        <b>RBS:</b> <?php echo $rows_emp_appoint['blood_sugar_rbs'] ?>mg/dl
    </div>
<?php } ?>

<?php if ($rows_emp_appoint['blood_sugar_fbs'] != 0 || $rows_emp_appoint['blood_sugar_fbs'] != '') { ?>
    <div style="width: 15%; display: inline; font-size: 12px;">
        <b>FBS:</b> <?php echo $rows_emp_appoint['blood_sugar_fbs'] ?>mg/dl
    </div>
<?php } ?>

<?php if ($rows_emp_appoint['blood_sugar_ppbs'] != 0 || $rows_emp_appoint['blood_sugar_ppbs'] != '') { ?>
    <div style="width: 15%; display: inline; font-size: 12px;">
        <b>PPBS:</b> <?php echo $rows_emp_appoint['blood_sugar_ppbs'] ?> mg/dl
    </div>
<?php } ?>

<?php if ($rows_emp_appoint['respiratory_rate'] != 0 && $rows_emp_appoint['respiratory_rate'] != '') { ?>
    <div style="width: 15%; display: inline; font-size: 12px; text-transform: capitalize;">
        <b>Respiratory Rate:</b> <?php echo $rows_emp_appoint['respiratory_rate'] ?>
    </div>
<?php } ?>

<?php if ($rows_emp_appoint['urine_ouput'] != 0 || $rows_emp_appoint['urine_ouput'] != '') { ?>
    <div style="width: 15%; display: inline; font-size: 12px; text-transform: capitalize;">
        <b>Urine Output:</b> <?php echo $rows_emp_appoint['urine_ouput'] ?>
    </div>
<?php } ?>


<?php if ($rows_emp_appoint['avpu'] != 0 && $rows_emp_appoint['avpu'] != '') { ?>
    <div style="width: 15%; display: inline; font-size: 12px; text-transform: capitalize;">
        <b>AVPU:</b> <?php echo $rows_emp_appoint['avpu'] ?>
    </div>
<?php } ?>

<?php if ($rows_emp_appoint['trama'] != 0 && $rows_emp_appoint['trama'] != '') { ?>
    <div style="width: 15%; display: inline; font-size: 12px; text-transform: capitalize;">
        <b>Trama:</b> <?php echo $rows_emp_appoint['trama'] ?>
    </div>
<?php } ?>

<?php if ($rows_emp_appoint['mobility'] != 0 && $rows_emp_appoint['mobility'] != '') { ?>
    <div style="width: 15%; display: inline; font-size: 12px; text-transform: capitalize;">
        <b>Mobility:</b> <?php echo $rows_emp_appoint['mobility'] ?>
    </div>
<?php } ?>

<?php if ($rows_emp_appoint['oxygen_supply'] != 0 && $rows_emp_appoint['oxygen_supply'] != '') { ?>
    <div style="width: 15%; display: inline; font-size: 12px; text-transform: capitalize;">
        <b>Oxygen Supplementation:</b> <?php echo $rows_emp_appoint['oxygen_supply'] ?>
    </div>
<?php } ?>

<?php if ($rows_emp_appoint['glasgow_coma_scale'] != 0 && $rows_emp_appoint['glasgow_coma_scale'] != '') { ?>
    <div style="width: 15%; display: inline; font-size: 12px; text-transform: capitalize;">
        <b>Glasgow coma scale:</b> <?php echo $rows_emp_appoint['glasgow_coma_scale'] ?>
    </div>
<?php } ?>

<?php if ($rows_emp_appoint['total_cholesterol'] != 0 && $rows_emp_appoint['total_cholesterol'] != '') { ?>
    <div style="width: 15%; display: inline; font-size: 12px; text-transform: capitalize;">
        <b>Total Cholesterol:</b> <?php echo $rows_emp_appoint['total_cholesterol'] ?>
    </div>
<?php } ?>
<br>
<br>


<table width="100%">




    <tr>

        <td width="15%"><strong>Case Type:</strong>
            <?php if (strcmp($rows_emp_appoint['case_type'], 'NEW') == 0) {
                echo 'NEW CASE';
            }
            if (strcmp($rows_emp_appoint['case_type'], 'REP') == 0) {
                echo 'REPEAT';
            }
            if (strcmp($rows_emp_appoint['case_type'], 'FUP') == 0) {
                echo 'FOLLOW UP';
            }
            if (strcmp($rows_emp_appoint['case_type'], 'MED') == 0) {
                echo 'MEDICATION';
            }   ?>
        </td>

        <td width="30%"><b>Referred By:</b>
            <?php echo getFieldFromTable('referred_by', 'referred_by_master', 'id', $referred_by); ?></td>

        </td>

    </tr>

    <?php

    $findings_ids = $rows_emp_appoint['examination_remarks'];
    $findings_ids_array = array();
    $findings_ids_array = explode(",", $findings_ids);
    $findings = "";
    for ($i = 0; $i < count($findings_ids_array); $i++) {
        if ($i == 0) {
            $findings = getTableFieldValue('examination_findings', 'examination_finding', 'id', $findings_ids_array[$i]);
        } else {
            $findings = $findings . "," . getTableFieldValue('examination_findings', 'examination_finding', 'id', $findings_ids_array[$i]);
        }
    }

    $complaint_ids = $rows_emp_appoint['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];
            }
        }
    }

    $referral_ids = $rows_emp_appoint['referral'];
    $referral_ids_array = array();
    $referral_ids_array = explode(",", $referral_ids);
    $referral = "";
    for ($i = 0; $i < count($referral_ids_array); $i++) {
        if ($i == 0) {
            $referral = getTableFieldValue('referral_point', 'referral_point_name', 'referral_point_id', $referral_ids_array[$i]);
        } else {
            $referral = $referral . "," . getTableFieldValue('referral_point', 'referral_point_name', 'referral_point_id', $referral_ids_array[$i]);
        }
    }

    ?>



    <tr>

        <td width="30%"><b>Complaints :</b> <?php echo $complaints ?></td>


        <td width="30%" align="left"><b>Examination :</b> <?php echo $findings; ?></td>


    </tr>

    <tr>

        <td width="32%" align="left"><b>Remarks/Follow-up
                Investigation Details:</b> <?php echo nl2br($rows_emp_appoint['remarks_rece']) ?></td>

        <td width="32%" align="left"><b>Ecg Finding:</b> <?php echo nl2br($rows_emp_appoint['ecg_findings']) ?></td>

    </tr>

    <?php
    $ailment_names_ids = $rows_emp_appoint['ailments_new'];
    $ailment_names_ids_array = array();
    $ailment_names_ids_array = explode(",", $ailment_names_ids);
    $ailment_names = "";
    for ($i = 0; $i < count($ailment_names_ids_array); $i++) {
        if ($i == 0) {
            $ailment_names = getTableFieldValue('ailment', 'ailment_name', 'ailment_id', $ailment_names_ids_array[$i]);
        } else {
            $ailment_names = $ailment_names . "," . getTableFieldValue('ailment', 'ailment_name', 'ailment_id', $ailment_names_ids_array[$i]);
        }
    }
    $ailment_system_ids = $rows_emp_appoint['ailment_systems_new'];
    $ailment_system_ids_array = array();
    $ailment_system_ids_array = explode(",", $ailment_system_ids);
    $ailment_systems = "";
    for ($i = 0; $i < count($ailment_system_ids_array); $i++) {
        if ($i == 0) {
            $ailment_systems = getTableFieldValue('ailment_system', 'ailment_sys_name', 'ailment_sys_id', $ailment_system_ids_array[$i]);
        } else {
            $ailment_systems = $ailment_systems . "," . getTableFieldValue('ailment_system', 'ailment_sys_name', 'ailment_sys_id', $ailment_system_ids_array[$i]);
        }
    }

    ?>



    <tr>

        <td width="12%"><b>Diagnosis:</b> <?php echo strtoupper($ailment_names) ?></td>


        <td width="20%" align="left"><b>Body System:</b> <?php echo $ailment_systems; ?></td>


    </tr>

    <tr>

        <td width="20%" align="left"><b>Disease Type:</b> <?php echo $disease_type; ?></td>

        <td><b>Advices:</b> <?php echo nl2br($health_advices) ?></td>

    </tr>

    <tr>

        <td width="20%" align="left"><b>Heart Rate:</b> <?php echo $heart_rate; ?></td>

        <td><b>Urine:</b> <?php echo $urine_output ?></td>

    </tr>








</table>

<?php if ($rows_emp_appoint['is_detention'] == 'Y') { ?>

    <h4>Detention Details</h4>

    <table class="table table-striped table-bordered table-hover" style="width: 100%; border: 1px;">
        <tr bgcolor="#eeeeee">
            <td width="4%"><b>Sr</b></td>
            <td width="20%"><b>Medicine</b></td>
            <td width="15%"><b>Admin. Route</b></td>
            <td width="10%"><b>Qty Issued</b></td>
        </tr>

        <?php $sql_detention = "select * from detention_intake where det_id = '" . $appoint_id . "'";
        $result_detention = mysqli_query($conn, $sql_detention);
        $count = 0;
        while ($row_detention = mysqli_fetch_array($result_detention)) {
            $medicine = $row_detention['medicine'];
            $srno = $count + 1;
            $unit_id = getFieldFromTable("unit_id", "tbl_items", "item_id", $medicine);
        ?>

            <tr>
                <td><?php echo $srno ?></td>
                <td><?php echo getItemWithFormName($medicine) ?></td>
                <td><?php echo strtoupper(getTableFieldValue('dosage_category', 'dosage_category', 'dosage_category_id', $row_detention['administration_route'])) ?>
                </td>
                <td><?php echo $row_detention['issued_qty'] ?> <?php echo $unitMap[$unit_id] ?> </td>
            </tr>

        <?php $count++;
        } ?>

    </table>


    <h4>Rx</h4>

<?php } ?>

<br>

<table border="0" width="100%">





</table>


<?php $appointment_id = $appoint_id; ?>

<?php include('treatment_view_common.php'); ?>

<br>
<table width="100%">
    <!-- <tr>
        <td width="70%"><b>Total Cost: </b> <?= $total_pay_cost ?></td>
    </tr> -->
    <tr>

        <td width="70%"><b>Additional Treatment Recommendations(if
                Any):</b> <?php echo nl2br($rows_emp_appoint['external_treatments']) ?></td>

    </tr>
    <?php
    $dr_name = getTableFieldValue('referral_point', 'referral_point_name', 'referral_point_id', $rows_emp_appoint['referral']);
    $spe = getTableFieldValue('referral_point', 'city', 'referral_point_id', $rows_emp_appoint['referral']);
    $hospital_name = getTableFieldValue('referral_point', 'hospital_name', 'referral_point_id', $rows_emp_appoint['referral']);

    ?>


    <tr>

        <td width="50%" align="left"><b>Referral:</b> <?php echo $dr_name . " - " . $spe . "(" . $hospital_name . ")"; ?></td>


        <td width="50%" align="left"><b>Follow-up date:</b><?php
                                                            $followup_date = date_create($rows_emp_appoint['followup']);
                                                            if (!empty($rows_emp_appoint['followup'])) {
                                                                echo date_format($followup_date, "d/m/Y");
                                                            }

                                                            // echo $rows_emp_appoint['followup'] 
                                                            ?>
        </td>



    </tr>

    <tr>

        <td width="50%" align="left"><b>Health Advices:</b> <?php echo $rows_emp_appoint['health_advices_new'] ?></td>


        <td width="50%" align="left"><b>Recommended Tests:</b><?php
                                                                echo determineDataFormat($rows_emp_appoint['recommended_tests_new'])
                                                                ?>
        </td>



    </tr>

    <tr>

        <td width="50%" align="left"><b>Additional Precautions:</b> <?php echo  $rows_emp_appoint['remarks'] ?></td>


        <td width="50%" align="left"><b>Chronic Illness:</b><?php
                                                            echo getCommaSeperatedValuesForInClause("select abnormality_name from  abnormality", "abnormality_id", $rows_emp_appoint['abnormalitys']);
                                                            ?>
        </td>



    </tr>
    <?php

    $sql_get_sick = "SELECT date_absent,date_absent_to,half_day FROM sickness WHERE  followup_to_opd = '" . $appoint_id . "' and  followup_id = '" . $followup_id . "' ";
    error_log("error" . $sql_get_sick);
    // echo $sql_get_sick;

    error_log("OPD PDF QUERY:" . $sql_get_sick);

    $res_det_sick = mysqli_query($conn, $sql_get_sick);

    $data_for_sick = mysqli_fetch_array($res_det_sick);

    @extract($data_for_sick);

    ?>



    <tr>
        <td width="50%" align="left"><b>Period Of Rest From:</b><?php
                                                                $rest_from_time = date_create($data_for_sick['date_absent']);
                                                                if (!empty($data_for_sick['date_absent'])) {
                                                                    echo date_format($rest_from_time, "d/m/Y");
                                                                }


                                                                ?>
        </td>

        <td width="50%" align="left"><b>Period Of Rest To:</b><?php
                                                                $rest_to_time = date_create($data_for_sick['date_absent_to']);
                                                                if (!empty($data_for_sick['date_absent_to'])) {
                                                                    echo date_format($rest_to_time, "d/m/Y");
                                                                }


                                                                ?></td>






    </tr>
    <tr>

        <td width="50%" align="left"><b>Half Day:</b><?php if ($data_for_sick['half_day'] == 1) {
                                                            echo "YES";
                                                        } ?>
        </td>
        <td><b>Precautions:</b> <?php echo nl2br($rows_emp_appoint['remarks']) ?></td>

    </tr>

    <tr>
        <td width="50%" align="left"><b>Leave Remarks:</b><?php
                                                            echo $rows_emp_appoint['injury_remarks'];


                                                            ?>
        </td>
        <?php if ($rows_emp_appoint['health_status'] == 'fit') {
            $h_status = 'Fit';
        } else if ($rows_emp_appoint['health_status'] == 'unfit_ob') {
            $h_status = 'Unfit Observation';
        } else if ($rows_emp_appoint['health_status'] == 'unfit_ref') {
            $h_status = 'Unfit Referral';
        } else {
            $h_status = '';
        } ?>


        <td><b>Status: </b> <?php echo $h_status ?></td>



    </tr>


    <!-- <tr>

        <td><b>Medical Tests Recommended:</b> <?php echo nl2br(determineDataFormat($tests)) ?></td>

    </tr> -->

    <tr>

        <td><b>Followup-Remarks:</b> <?php echo nl2br($rows_emp_appoint['followup_remarks']) ?></td>
      

    </tr>
    <tr>
        <td colspan="2"><b>Observation Note</b> <?php echo nl2br($rows_emp_appoint['observation_note']) ?></td>
    </tr>
    <tr>
        <td colspan="2"><b>Previous Medical History:</b> <?php echo nl2br($rows_emp_appoint['pre_med_history']) ?></td>
    </tr>
    <tr>
        <td colspan="2"><b>Current Medical History:</b> <?php echo nl2br($rows_emp_appoint['doc_comment']) ?></td>
    </tr>

</table>

<br>
<table width="100%">
    <tr>
        <td><img src="data:<?php echo $row_doc_details['image_type'] ?>;base64,<?php echo base64_encode($row_doc_details['emp_sign']) ?>" style="width: 120px; height: 80px;float: right" /></td>
    </tr>

</table>

<br>
<br>
<br>
<br>
<table width="100%">
    <tr>
        <td><strong style="float: right;">Signature & Stamp</strong></td>
    </tr>
</table>
<br>
<!-- <table width="100%">
    <tr>
        <td><strong style="float: right;">
                <?php if ($_SESSION['RoleCode' == 'DOC']) {
                    echo "Dr.$doc_name";
                } else {
                    echo $doc_name;
                }
                ?>
            </strong></td>
    </tr>
</table>
<br> -->
<!-- <table width="100%">
    <tr>

        <td><strong style="float: right;">Regd. No.:
                <?php echo $row_doc_details['registration_no'] ?>
            </strong></td>
    </tr>

</table> -->


<br>

<hr>
<table cellspacing="0" width="100%">
    <tr>

        <td style="text-align:center">
            <strong>PREVENTION IS BETTER THAN CURE</strong>
        </td>
    </tr>
    <tr>
        <td style="text-align: center">
            <strong>NOTE: NOT FOR USE MEDICO LEGAL PURPOSES</strong>
        </td>
    </tr>
</table>




</form>

<form id="employeeDetailsFormPdf" action="" method="POST">

    <input type="hidden" name="htmlText" id="htmlText" />

</form>
</div>
<script>
    formSubmit();

    function formSubmit() {

        $("#htmlText").val($("#opd_form").html());

        document.forms['employeeDetailsFormPdf'].action = "pdf_dynamic.php";

        document.forms['employeeDetailsFormPdf'].method = "post";

        document.forms['employeeDetailsFormPdf'].submit();

    }
</script>