<?php include("../../../includes/config.php");
require_once('tcpdf_include.php');
isAdminLoggedIn();
$id = isset($_GET['id']) ? $_GET['id'] :'';
$opd_no ='';
$opd_name='';
$opd_diagnosis='';
$opd_date='';
$opd_religion='';
$opd_gender='';
$opd_occupation='';
$opd_age ='';
$opd_address='';
$opd_visitnumberoftime='';
$opd_reffer_department='';
$complaints='---';
$modalities_agg ='---';
$modalities_amet='---';
$concomitant='---';
$opd_personal_history='---';
$opd_past_history='---';
$opd_family_history='---';
$opd_physical_examination='---';
$opd_pulse ='---';
$opd_bp='---';
$opd_temp='---';
$opd_respiration='---';
$opd_appetite='---';
$opd_desire='---';
$opd_aversion='---';
$opd_thrist='---';
$opd_urine='---';
$opd_stool='---';
$opd_thermal_state='---';
$opd_menstrual='---';
$opd_weight='---';
$opd_systemic_examination='---';
$opd_cvs='---';
$opd_cns='---';
$opd_git='---';
$opd_respiratory='---';
$opd_reproductive='---';
$opd_locomoter='';
$opd_skin='---';
$opd_mind='---';
$opd_sleep_dream='---';
$opd_symptoms='---';
$opd_othe_advises='---';
$opd_repertory='---';
$opd_diagnosis='';
$opd_lab='---';
$opd_xray='---';
$opd_usg='---';
$opd_ecg='---';
$opd_ot='---';
$opd_ipd='---';
$diagnosis_name='';
$opd_reffer_doctor='';
$opd_visitnumberoftime='';
$opd_status='';
$opd_srnumber='';
$opd_old_new='';
$opd_no_for_search='';
if($id!=''){
    $opd_no_get_qry = "SELECT opd_other.*,opd.opd_no,
    opd.opd_name,
    opd.opd_date,
    opd.opd_religion,
    opd.opd_gender,
    opd.opd_occupation,
    opd.opd_age,
    opd.opd_address,
    opd.opd_visitnumberoftime,
    opd.opd_reffer_department,
    complaints.complaints,
    complaints.modalities_agg,
    complaints.modalities_amet,
    complaints.concomitant,
    diagnosis.diagnosis_name

    FROM hp_opd as opd 
    LEFT JOIN hp_opd_other_details as opd_other ON opd.opd_id=opd_other.opd_id_fk
    LEFT JOIN hp_opd_ipd_complaints as complaints ON opd.opd_id=complaints.opd_id_fk
    LEFT JOIN  hp_diagnosis as diagnosis ON opd_other.opd_diagnosis=diagnosis.diagnosis_id 
    WHERE  opd.opd_status='Active' and opd.opd_id='".$id."' ";
    $patient_search = $db->selectOne($opd_no_get_qry);
 
  
    if($patient_search['opd_no']!=''){ $opd_no = $patient_search['opd_no']; }
    if($patient_search['opd_name']!=''){ $opd_name = $patient_search['opd_name']; }
    if($patient_search['opd_diagnosis']!=''){ $opd_diagnosis = $patient_search['opd_diagnosis']; }
    if($patient_search['opd_date']!=''){ $opd_date = $patient_search['opd_date']; }
    if($patient_search['opd_religion']!=''){ $opd_religion = $patient_search['opd_religion']; }
    if($patient_search['opd_gender']!=''){ $opd_gender = $patient_search['opd_gender']; }
    if($patient_search['opd_occupation']!=''){ $opd_occupation = $patient_search['opd_occupation']; }
    if($patient_search['opd_age']!=''){ $opd_age = $patient_search['opd_age']; }
    if($patient_search['opd_address']!=''){ $opd_address = $patient_search['opd_address']; }
    if($patient_search['opd_visitnumberoftime']!=''){ $opd_visitnumberoftime=trim($patient_search['opd_visitnumberoftime']); }
    if($patient_search['opd_reffer_department']!=''){ $opd_reffer_department = $patient_search['opd_reffer_department']; }
    // complaints
    if($patient_search['complaints']!=''){ $complaints = $patient_search['complaints']; }

    if(trim($patient_search['modalities_agg'])!='' and $patient_search['modalities_agg']!='0'){ $modalities_agg = $patient_search['modalities_agg'];  }else{ $modalities_agg = ''; }
    
    if($patient_search['modalities_amet']!='' and $patient_search['modalities_amet']!='0'){ $modalities_amet = $patient_search['modalities_amet']; }else{ $modalities_amet ="";}
  
    if($patient_search['concomitant']!=''){ $concomitant = $patient_search['concomitant']; }
        
    // history
    if($patient_search['opd_personal_history']!=''){ $opd_personal_history = $patient_search['opd_personal_history']; }
    if($patient_search['opd_past_history']!=''){ $opd_past_history = $patient_search['opd_past_history']; }
    if($patient_search['opd_family_history']!=''){ $opd_family_history = $patient_search['opd_family_history']; }
    if($patient_search['opd_physical_examination']!=''){ $opd_physical_examination = $patient_search['opd_physical_examination']; }
   
    // pulse ext
    if($patient_search['opd_pulse']!=''){ $opd_pulse = $patient_search['opd_pulse']; }
    if($patient_search['opd_bp']!=''){ $opd_bp = $patient_search['opd_bp']; }
    if($patient_search['opd_temp']!=''){ $opd_temp = $patient_search['opd_temp']; }
    if($patient_search['opd_respiration']!=''){ $opd_respiration = $patient_search['opd_respiration']; }
    if($patient_search['opd_appetite']!=''){ $opd_appetite = $patient_search['opd_appetite']; }
    if($patient_search['opd_desire']!=''){ $opd_desire = $patient_search['opd_desire']; }
    if($patient_search['opd_aversion']!=''){ $opd_aversion = $patient_search['opd_aversion']; }
    if($patient_search['opd_thrist']!=''){ $opd_thrist = $patient_search['opd_thrist']; }
    if($patient_search['opd_urine']!=''){ $opd_urine = $patient_search['opd_urine']; }
    if($patient_search['opd_stool']!=''){ $opd_stool = $patient_search['opd_stool']; }
    if($patient_search['opd_thermal_state']!=''){ $opd_thermal_state = $patient_search['opd_thermal_state']; }
    if($patient_search['opd_menstrual']!=''){ $opd_menstrual = $patient_search['opd_menstrual']; }
    if($patient_search['opd_weight']!=''){ $opd_weight = $patient_search['opd_weight']; }
    
    // systemic
    if($patient_search['opd_systemic_examination']!=''){ $opd_systemic_examination = $patient_search['opd_systemic_examination']; }
    
    if($patient_search['opd_cvs']!=''){ $opd_cvs = $patient_search['opd_cvs']; }
    if($patient_search['opd_cns']!=''){ $opd_cns = $patient_search['opd_cns']; }
    if($patient_search['opd_git']!=''){ $opd_git = $patient_search['opd_git']; }
    if($patient_search['opd_respiratory']!=''){ $opd_respiratory = $patient_search['opd_respiratory']; }
    if($patient_search['opd_reproductive']!=''){ $opd_reproductive = $patient_search['opd_reproductive']; }
    if($patient_search['opd_locomoter']!=''){ $opd_locomoter = $patient_search['opd_locomoter']; }
    if($patient_search['opd_skin']!=''){ $opd_skin = $patient_search['opd_skin']; }

    if($patient_search['opd_mind']!=''){ $opd_mind = $patient_search['opd_mind']; }
    if($patient_search['opd_sleep_dream']!=''){ $opd_sleep_dream = $patient_search['opd_sleep_dream']; }
    if($patient_search['opd_symptoms']!=''){ $opd_symptoms = $patient_search['opd_symptoms']; }
    if($patient_search['opd_othe_advises']!=''){ $opd_othe_advises = $patient_search['opd_othe_advises']; }
    if($patient_search['opd_repertory']!=''){ $opd_repertory = $patient_search['opd_repertory']; }
    if($patient_search['opd_diagnosis']!=''){ $opd_diagnosis = $patient_search['opd_diagnosis']; }

    if($patient_search['opd_lab']!=''){ $opd_lab = $patient_search['opd_lab']; }
    if($patient_search['opd_xray']!=''){ $opd_xray = $patient_search['opd_xray']; }
    if($patient_search['opd_usg']!=''){ $opd_usg = $patient_search['opd_usg']; }
    if($patient_search['opd_ecg']!=''){ $opd_ecg = $patient_search['opd_ecg']; }
    if($patient_search['opd_ot']!=''){ $opd_ot = $patient_search['opd_ot']; }
    if($patient_search['opd_ipd']!=''){ $opd_ipd = $patient_search['opd_ipd']; }
    if($patient_search['diagnosis_name']!=''){ $diagnosis_name = $patient_search['diagnosis_name']; }
    if($patient_search['opd_reffer_doctor']!=''){ $opd_reffer_doctor = $patient_search['opd_reffer_doctor']; }
    if($patient_search['opd_ipd']=='Yes'){
        $ipd_get_qry = 'SELECT ipd_no FROM hp_ipd WHERE opd_id_fk="'.$id.'"';
        $ipd_get = $db->selectOne($ipd_get_qry);
        $ipd_no=$ipd_get['ipd_no'];
    }else{
        $ipd_no='';
    }
    
    
    
   
    
    if(empty($patient_search)){
        echo "<script>alert('OPD Number Not Found.')</script>";
        //echo "<script>window.location.href = 'opdlist.php';</script>";
    }
}
function rmws($input){
    $input = preg_replace("/[^a-zA-Z0-9\-\&\,\>\<]+/", " ", $input);
    return $input;
}
class MYPDF extends TCPDF {
    public function ColoredTable($header,$data) {
            // Colors, line width and bold font
            $this->SetFillColor(128,128,128);
            $this->SetTextColor(255);
            
            $this->SetLineWidth(0.3);
            $this->SetFont('', 'B');
            // Header
            $w = array(40, 35, 40, 45);
            $num_headers = count($header);
            for($i = 0; $i < $num_headers; ++$i) {
                $this->Cell($w[$i], 7, $header[$i], 1, 0, 'C', 1);
            }
            $this->Ln();
            // Color and font restoration
            $this->SetFillColor(224, 235, 255);
            $this->SetTextColor(0);
            $this->SetFont('');
            // Data
            $fill = 0;
            foreach($data as $row) {
                $this->Cell($w[0], 6, $row[0], 'LR', 0, 'L', $fill);
                $this->Cell($w[1], 6, $row[1], 'LR', 0, 'L', $fill);
                $this->Cell($w[2], 6, $row[2], 'LR', 0, 'R', $fill);
                $this->Cell($w[3], 6, $row[3], 'LR', 0, 'R', $fill);
                $this->Ln();
                $fill=!$fill;
            }
            $this->Cell(array_sum($w), 0, '', 'T');
    }
    function plot_table($widths, $lineheight, $table, $border=1, $aligns=array(), $fills=array(), $links=array()){
        $func = function($text, $c_width){
            $len=strlen($text);
            $twidth = $this->GetStringWidth($text);
            $split = floor($c_width * $len / $twidth);
            $w_text = explode( "\n", wordwrap( $text, $split, "\n", true));
            return $w_text;
        };
        foreach ($table as $line){
            $line = array_map($func, $line, $widths);
            $maxlines = max(array_map("count", $line));
            foreach ($line as $key => $cell){
                $x_axis = $this->getx();
                $height = $lineheight * $maxlines / count($cell);
                $len = count($line);
                $width = (isset($widths[$key]) === TRUE ? $widths[$key] : $widths / count($line));
                $align = (isset($aligns[$key]) === TRUE ? $aligns[$key] : '');
                $fill = (isset($fills[$key]) === TRUE ? $fills[$key] : false);
                $link = (isset($links[$key]) === TRUE ? $links[$key] : '');
                foreach ($cell as $textline){
                    $this->cell($widths[$key],$height,$textline,0,0,$align,$fill,$link);
                    $height += 2 * $lineheight * $maxlines / count($cell);
                    $this->SetX($x_axis);
                }
                if($key == $len - 1){
                    $lbreak=1;
                }
                else{
                    $lbreak = 0;
                }
                $this->cell($widths[$key],$lineheight * $maxlines, '',$border,$lbreak);
            }
        }
    }
}
ob_clean();
$pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
// add a page
if($opd_visitnumberoftime=='1'){
    $pdf->AddPage();
    $pdf->SetFont('times','B',10);
    $html = '<table  border="1"  align="center" width="100%" style="border-color:blue;">';
        $html .= '<tr>';
            $html .= '<td height="15">';
            $html .='</td>';
        $html .='</tr>';
        $html .= '<tr align="center">';
            $html .= '<td height="25" style="background-color:#20364e;color:white;font-size:13px;">
                <table width="100%" cellpadding="5" align="center">
                    <tr>
                        <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NOBLE HOSPITAL (HOMOEOPATHIC & GENERAL)</td>
                    </tr>
                </table>';
            $html .='</td>';
        $html .='</tr>';
        $html .= '<tr>';
            $html .= '<td align="center" height="25" style="font-size:10px;color:#20364e;font-weight:normal;">
                <table width="100%" cellpadding="5">
                    <tr>
                        <td width="90"></td>
                        <td width="85%" align="center">Maneged By : SHREE VIVEK BHARTI TRUST - JUNAGADH & <br>  NOBLE HOMOEOPATHY MEDICAL COLLEGE & RESEARCH INSTITUTE - JUNAGADH</td>
                    </tr>
                </table>';
            $html .='</td>';
        $html .='</tr>';
        $html .= '<tr>';
            $html .= '<td align="center" height="25" style="font-size:10px;color:#20364e;font-weight:normal;">
                <table width="100%" cellpadding="5">
                    <tr>
                        <td width="90"></td>
                        <td width="85%" align="center">"PARTH VATIKA" ,Bhesan Road , Near Bamangam , Junagadh 362310</td>
                    </tr>
                </table>';
            $html .='</td>';
        $html .='</tr>';
    $html .= '</table>';
    $pdf->writeHTML($html, false, 0, false, 0);
    $pdf->Image('../../../img/cashlogo.jpg',13,12,22,30,'JPEG');
    $html = '<table  border="1"  align="center" width="100%" style="border-color:blue;">';
        $html .= '<tr align="center">';
            $html .= '<td height="25">
                <table width="100%" cellpadding="5" align="center">
                    <tr>
                        <td width="20%"></td>
                        <td width="60%" style="background-color:#20364e;color:white;font-size:12px;">OUT PATIENT DEPARTMENT</td>
                        <td width="20%"></td>
                    </tr>
                </table>';
            $html .='</td>';
        $html .='</tr>';
    $html .= '</table>';
    $pdf->writeHTML($html, false, 0, false, 0);
    $html = '<table width="100%" cellpadding="5" align="left" border="1" style="color:#20364e;font-size:9px;">
                <tr>
                    <td>OPD No. : '.$opd_no.'</td>
                    <td>DATE    : '.date('d-m-Y',strtotime($opd_date)).'</td>
                    <td>Ref. to (IPD) : '.$opd_ipd.'</td>
                    <td>Case : New </td>
                </tr>
                <tr>
                    <td colspan="3">Name : '.ucwords($opd_name).'</td>
                    <td>Occupation    : '.ucwords($opd_occupation).'</td>
                </tr>
                <tr>
                    <td>Sex  : '.ucwords($opd_gender).'</td>
                    <td>Age  : '.ucwords($opd_age).'</td>
                    <td>Caste  : '.ucwords($opd_religion).'</td>
                    <td>Department  : '.getdepartmentname($opd_reffer_department).'</td>
                </tr>
                 <tr>
                    <td colspan="4">Address  : '.ucwords($opd_address).'</td>
                </tr>
            </table>';
    $pdf->writeHTML($html, false, 0, false, 0);
   
    
    $modalities = '';
    if($modalities_agg!=''){
        $modalities .= $modalities_agg;
    }
    if($modalities_agg!=''){
        $modalities .= $modalities_amet;
    }
   
    if($complaints!=''){
        $complaints = rmws($complaints);
    }else{
        $complaints = '---';
    }
   
    $html = '<table width="100%"  cellpadding="5" align="left" border="1" style="color:#20364e;font-size:9px;font-weight:normal;">
       <tr>
            <td width="70%" height="180px"><b>Present ( Chief ) Complaints :</b> <br>'.nl2br($complaints).'</td>
            <td width="15%"><b>Modalities :</b> <br>'.htmlentities($modalities).'</td>
            <td width="15%"><b>Concomitant :</b> <br>'.$concomitant.'</td>
        </tr>
    </table>';
    
    $pdf->writeHTML($html, false, 0, false, 0);
    $html = '<table width="100%"  cellpadding="5" align="left" border="1" style="color:#20364e;font-size:9px;font-weight:normal;">
       <tr >
            <td width="33%" height="100px"><center><b>Personal History :</b></center> <br>'.rmws(nl2br($opd_personal_history)).'</td>
            <td width="37%"><center><b>Past History :</b></center> <br>'.rmws(nl2br($opd_past_history)).'</td>
            <td width="30%"><center><b>Family History :</b></center> <br>'.rmws(nl2br($opd_family_history)).'</td>
        </tr>
    </table>';
    $pdf->writeHTML($html, false, 0, false, 0);
   
    $html = '<table width="100%"  cellpadding="5" align="left" border="1" style="color:#20364e;font-size:9px;font-weight:normal;">
       <tr >
            <td width="50%" height="100px"><center><b>Physical Examination :</b></center> <br>'.rmws(nl2br($opd_physical_examination)).'</td>
            <td width="50%"><center><b>Systemic  Examination :</b></center> <br>'.rmws(nl2br($opd_systemic_examination)).'</td>
           
        </tr>
    </table>';
    $pdf->writeHTML($html, false, 0, false, 0);
    $html = '<table width="100%"  cellpadding="5" align="left" border="1" style="color:#20364e;font-size:10px;font-weight:normal;">
       <tr >
            <td width="50%" height="150px">
                <table border="0">
                    <tr>
                        <td width="30%">Pulse : <u>'.$opd_pulse.' </u></td>
                        <td width="30%">B.P. : <u>'.$opd_bp.' </u></td>
                        <td width="30%">Temp : <u>'.$opd_temp.' </u></td>
                    </tr>
                    <tr>
                        <td width="30%">R/R : <u>'.$opd_respiration.' </u></td>
                        <td width="70%">Appetite : <u>'.$opd_appetite.' </u></td>
                    </tr>
                    <tr>
                        <td width="100%">Desire /  <u>'.$opd_desire.' </u></td>
                  
                    </tr>
                    <tr>
                        <td width="100%">Aversion : <u>'.$opd_aversion.' </u></td>
                  
                    </tr>
                    <tr>
                        <td width="50%">Thrist : <u>'.$opd_thrist.' </u></td>
                        <td width="50%">Urine : <u>'.$opd_urine.' </u></td>
                  
                    </tr>
                     <tr>
                        <td width="100%">Stool : <u>'.$opd_stool.' </u></td>
                  
                    </tr>
                    <tr>
                        <td width="50%">Thermal State  : <u>'.$opd_thermal_state.' </u></td>
                        <td width="50%">Menstrual H/o : <u>'.$opd_menstrual.' </u></td>
                  
                    </tr>
                </table>
            </td>
            <td width="50%" height="150px">
                <table border="0">
                    <tr>
                        <td width="100%">CVS : <u>'.$opd_cvs.' </u></td>
                      
                    </tr>
                    <tr>
                        <td width="100%">CNS : <u>'.$opd_cns.' </u></td>
                      
                    </tr>
                    <tr>
                        <td width="100%">GIT : <u>'.$opd_git.' </u></td>
                      
                    </tr>
                    <tr>
                        <td width="100%">Respiratory : <u>'.$opd_respiratory.' </u></td>
                      
                    </tr>
                    <tr>
                        <td width="100%">Repoductive (M/F) : <u>'.$opd_reproductive.' </u></td>
                      
                    </tr>
                    <tr>
                        <td width="100%">Locomoter : <u>'.$opd_locomoter.' </u></td>
                      
                    </tr>
                    <tr>
                        <td width="100%">Skin : <u>'.$opd_skin.' </u></td>
                      
                    </tr>
                </table>
            </td>
           
        </tr>
    </table>';
    $pdf->writeHTML($html, false, 0, false, 0);
    $pdf->AddPage();
    $html = '<table width="100%"  cellpadding="5" align="left" border="1" style="color:#20364e;font-size:9px;font-weight:normal;">
       <tr >
            <td width="70%" height="110px"><center><b>Mind :</b></center> <br>'.rmws(nl2br($opd_mind)).'</td>
            <td width="30%"><center><b>Sleep & Dreams  :</b></center> <br>'.rmws(nl2br($opd_sleep_dream)).'</td>
           
        </tr>
    </table>';
    $pdf->writeHTML($html, false, 0, false, 0);
    $data='';
    if($opd_lab=="Yes"){ 
        $data .=" Laboratory : ".$opd_lab;
    } 
    if($opd_xray=="Yes"){ 
        $data .=" X-ray : ".$opd_lab;
    }
    if($opd_usg=="Yes"){ 
        $data .= " USG :  ".$opd_usg;
    } 
    if($opd_ecg=="Yes"){ 
        $data .= " ECG :  ".$opd_ecg;
    } 
    if($opd_ot=="Yes"){ 
        $data .= " OT :   ".$opd_ot;
    }
    if($data==''){$data ='---';}
    $html = '<table width="100%"  cellpadding="5" align="left" border="1" style="color:#20364e;font-size:9px;font-weight:normal;">
       <tr >
            <td width="100%" height="90px"><center><b>Investigations :</b></center> <br>'.nl2br($data).'</td>
           
           
        </tr>
    </table>';
    $pdf->writeHTML($html, false, 0, false, 0);

    $html = '<table width="100%"  cellpadding="5" align="left" border="1" style="color:#20364e;font-size:9px;font-weight:normal;">
       <tr >
            <td width="100%" height="110px"><center><b>Prescriptive :</b></center> <br>'.rmws(nl2br($opd_symptoms)).'</td>
           
           
        </tr>
    </table>';
    $pdf->writeHTML($html, false, 0, false, 0);

    $html = '<table width="100%"  cellpadding="5" align="left" border="1" style="color:#20364e;font-size:9px;font-weight:normal;">
       <tr >
            <td width="70%" height="80px"><center><b>Repertory :</b></center> <br>'.nl2br($opd_repertory).'</td>
            <td width="30%" height="80px"><center><b>Diagnosis :</b></center> <br>'.$diagnosis_name.'</td>
           
           
        </tr>
    </table>';
    $pdf->writeHTML($html, false, 0, false, 0);
    $html = '<table width="100%"   align="left" border="1" style="color:#20364e;font-size:9px;font-weight:normal;">
        <tr>
            <td height="180"> <br><b>Remeady</b> :<br><br>
                <table width="100%"  cellpadding="5" align="left" border="1" style="color:#20364e;font-size:9px;font-weight:normal;">
                   <tr >
                        <td>Medicine Name</td>
                        <td>Dosage</td>
                        <td>Day</td>
                        
                    </tr>';
    $opd_medicine_get_qry = 'SELECT mn.medicine_name_details_name as mname,md.medicinedosage_name as dosagename,pm.pom_medicine_stock as stock,pm.pom_medicine_days as days,pm.pom_unit as unit,mp.m_power_name as potancy FROM hp_provied_opd_patient_medicine as pm LEFT JOIN hp_medicine_name    as mn ON mn.medicine_name_details_id_pk = pm.pom_medicine_name LEFT JOIN hp_medicinedosage    as md ON md.medicinedosage_id    = pm.pom_medicine_dosage LEFT JOIN hp_medicine_power    as mp ON mp.m_power_id    = pm.pom_medicine_potency WHERE  pm.pom_opd_no="'.$opd_no.'" and pm.pom_visitnumberoftime="'.$opd_visitnumberoftime.'" order by pm.pom_id desc';
        $opd_medicine_get = $db->selectAll($opd_medicine_get_qry);

    if(!empty($opd_medicine_get)){
        foreach ($opd_medicine_get as $mvalue) {
            $html .='<tr>';
                $html .='<td>'.$mvalue['mname'].' - '.$mvalue['potancy'].'</td>';
                $html .='<td>'.$mvalue['dosagename'].'</td>';
                $html .='<td>'.$mvalue['days'].'</td>';
                // $html .='<td>'.$mvalue['stock'].'-'.$mvalue['unit'].'</td>';
            $html .='</tr>';
        }
        
    }
    $html .='</table></td></tr></table>';
    $pdf->writeHTML($html, false, 0, false, 0);
    $html = '<table width="100%"  cellpadding="5" align="left" border="1" style="color:#20364e;font-size:9px;font-weight:normal;">
       <tr >
            <td width="100%" height="90px"><center><b>Other Advises :</b></center> <br>'.nl2br(rmws($opd_othe_advises)).'</td>
        </tr>
    </table>';
    $pdf->writeHTML($html, false, 0, false, 0);
    $html = '<table width="100%"  cellpadding="5" align="left" border="0" style="color:#20364e;font-size:9px;font-weight:normal;">
       <tr >
            <td width="100%"><br><br><center><b>Doctor Name :</b></center> <u>'.ucwords($opd_reffer_doctor).'</u></td>
        </tr>
        <tr >
            <td width="100%" align="right"><b>Signature :</b> _________________________________</td>
        </tr>
    </table>';
    $pdf->writeHTML($html, false, 0, false, 0);
   
}else if($opd_visitnumberoftime>1){
    if($opd_visitnumberoftime=='2'){
        $pdf->AddPage();
        $pdf->Cell(190,10,':: FOLLOW UP PROGRESS NOTES ::',0,0,'C',false);
        $pdf->Ln();
        $pdf->Cell(60,10,'O.P.D. : '.$opd_no.'',0,0,'l',false);
        $pdf->Cell(130,10,'I.P.D. : '.$ipd_no.'',0,0,'R',false);
        $pdf->Ln();
        $opd_medicine_get_qry = 'SELECT mn.medicine_name_details_name as mname,md.medicinedosage_name as dosagename,pm.pom_medicine_stock as stock,pm.pom_medicine_days as days,pm.pom_unit as unit,mp.m_power_name as potancy FROM hp_provied_opd_patient_medicine as pm LEFT JOIN hp_medicine_name    as mn ON mn.medicine_name_details_id_pk = pm.pom_medicine_name LEFT JOIN hp_medicinedosage    as md ON md.medicinedosage_id    = pm.pom_medicine_dosage LEFT JOIN hp_medicine_power    as mp ON mp.m_power_id    = pm.pom_medicine_potency WHERE  pm.pom_opd_no="'.$opd_no.'" and pm.pom_visitnumberoftime="'.$opd_visitnumberoftime.'" order by pm.pom_id desc';
        $opd_medicine_get = $db->selectAll($opd_medicine_get_qry);
        $html = '<table height="33.33%">';
            $html .='<tr>';
                $html .='<td width="100%" height="33.33%" >';
                    $html .='<table border="1" cellpadding="5" style="color:#20364e;font-size:9px;font-weight:normal;">';
                        $html .='<tr >';
                            $html .='<td width="12%" ><b>Date</b></td>';
                            $html .='<td width="50%"><b>SYMPTOMS CHANGES :</b></td>';
                            $html .='<td width="38%"><b>Remeady :</b></td>';
                        $html .='</tr>';
                        $html .='<tr >';
                            $html .='<td width="12%" >'.date('d-m-Y',strtotime($opd_date)).'</td>';
                            $html .='<td width="50%">'.rmws(nl2br($opd_symptoms)).'</td>';
                            $html .='<td width="38%">';
                                if(!empty($opd_medicine_get)){
                                    foreach ($opd_medicine_get as $mvalue) {
                                        $html .=$mvalue['mname'].' - '.$mvalue['potancy'].' - '.$mvalue['dosagename'].' - '.$mvalue['days'].'<br>';
                                    }
                                }
                            $html .='</td>';
                        $html .='</tr>';
                    $html .='</table>';
                $html .='</td>';
            $html .='</tr>';
        $html .='</table>';

        $pdf->writeHTML($html, false, 0, false, 0);
    }
    // if ($opd_visitnumberoftime=='3'){
    //     $pdf->AliasNbPages();
    //     $pdf->AddPage();
    //     $pdf->SetFont('times','B',12);
    //     $pdf->Cell(190,88,'',0,0,'C',false);
    //     $pdf->ln();
    //     $pdf->SetFont('times','B',12);
    //     $pdf->SetFillColor(32, 54, 78,1);
    //     $pdf->SetTextColor(240,245,251,1);
    //     $pdf->Cell(25,7,'Date',1,0,'C',true);
    //     $pdf->Cell(65,7,'SYMPTOMS CHANGES',1,0,'C',true);
    //     $pdf->Cell(100,7,'Remeady',1,0,'C',true);
    //     $pdf->Ln();
    //     $pdf->SetFillColor(224,235,255);
    //     $pdf->SetTextColor(0);
    //     $pdf->SetFont('');
    //     $fill = false;
    //     $opd_medicine_get_qry = 'SELECT mn.medicine_name_details_name as mname,md.medicinedosage_name as dosagename,pm.pom_medicine_stock as stock,pm.pom_medicine_days as days,pm.pom_unit as unit FROM hp_provied_opd_patient_medicine as pm LEFT JOIN hp_medicine_name    as mn ON mn.medicine_name_details_id_pk = pm.pom_medicine_name LEFT JOIN hp_medicinedosage    as md ON md.medicinedosage_id    = pm.pom_medicine_dosage WHERE  pm.pom_opd_no="'.$opd_no.'" and pm.pom_visitnumberoftime="'.$opd_visitnumberoftime.'" order by pm.pom_id desc';
    //     $opd_medicine_get = $db->selectAll($opd_medicine_get_qry);
    //     $html='';
    //     if(!empty($opd_medicine_get)){
    //             $html =' Medicine Name'.str_repeat(' ', 15).' Dosage'.str_repeat(' ', 15).'  Day '."\r\n";
    //             foreach ($opd_medicine_get as $mvalue) {
    //                 $html .= $mvalue['mname'].str_repeat(' ', 15).$mvalue['dosagename'].str_repeat(' ', 15).$mvalue['days']."\r\n";
    //             }
    //     }
    //     $table = array(array(date('d-m-Y',strtotime($opd_date)), $opd_symptoms,$html));
    //     $widths = array(25,65,100);
    //     $lineheight = 8;
    //     $pdf->plot_table($widths, $lineheight, $table);
    //     $pdf->Cell(190,1,'',1,0,'C',TRUE);       
    //     $pdf->Output();
       
    // }
    // if ($opd_visitnumberoftime=='4'){
    //     $pdf->AliasNbPages();
    //     $pdf->AddPage();
    //     $pdf->SetFont('times','B',12);
    //     $pdf->Cell(190,88,'',0,0,'C',false);
    //     $pdf->ln();
    //     $pdf->Cell(190,88,'',0,0,'C',false);
    //     $pdf->ln();
    //     $pdf->SetFont('times','B',12);
    //     $pdf->SetFillColor(32, 54, 78,1);
    //     $pdf->SetTextColor(240,245,251,1);
    //     $pdf->Cell(25,7,'Date',1,0,'C',true);
    //     $pdf->Cell(65,7,'SYMPTOMS CHANGES',1,0,'C',true);
    //     $pdf->Cell(100,7,'Remeady',1,0,'C',true);
    //     $pdf->Ln();
    //     $pdf->SetFillColor(224,235,255);
    //     $pdf->SetTextColor(0);
    //     $pdf->SetFont('');
    //     $fill = false;
    //     $opd_medicine_get_qry = 'SELECT mn.medicine_name_details_name as mname,md.medicinedosage_name as dosagename,pm.pom_medicine_stock as stock,pm.pom_medicine_days as days,pm.pom_unit as unit FROM hp_provied_opd_patient_medicine as pm LEFT JOIN hp_medicine_name    as mn ON mn.medicine_name_details_id_pk = pm.pom_medicine_name LEFT JOIN hp_medicinedosage    as md ON md.medicinedosage_id    = pm.pom_medicine_dosage WHERE  pm.pom_opd_no="'.$opd_no.'" and pm.pom_visitnumberoftime="'.$opd_visitnumberoftime.'" order by pm.pom_id desc';
    //     $opd_medicine_get = $db->selectAll($opd_medicine_get_qry);
    //     $html='';
    //     if(!empty($opd_medicine_get)){
    //             $html =' Medicine Name'.str_repeat(' ', 15).' Dosage'.str_repeat(' ', 15).'  Day '."\r\n";
    //             foreach ($opd_medicine_get as $mvalue) {
    //                 $html .= $mvalue['mname'].str_repeat(' ', 15).$mvalue['dosagename'].str_repeat(' ', 15).$mvalue['days']."\r\n";
    //             }
    //     }
    //     $table = array(array(date('d-m-Y',strtotime($opd_date)), $opd_symptoms,$html));
    //     $widths = array(25,65,100);
    //     $lineheight = 8;
    //     $pdf->plot_table($widths, $lineheight, $table);
    //     $pdf->Cell(190,1,'',1,0,'C',TRUE);       
    //     $pdf->Output();
       
    // }
    // if($opd_visitnumberoftime=='5'){
    //    $pdf->AliasNbPages();
    //    $pdf->AddPage();
    //    $pdf->SetFont('times','B',12);
    //    $pdf->SetFillColor(32, 54, 78,1);
    //    $pdf->SetTextColor(240,245,251,1);
    //     $pdf->Cell(25,7,'Date',1,0,'C',true);
    //     $pdf->Cell(65,7,'SYMPTOMS CHANGES',1,0,'C',true);
    //     $pdf->Cell(100,7,'Remeady',1,0,'C',true);
    //     $pdf->Ln();
    //     $pdf->SetFillColor(224,235,255);
    //     $pdf->SetTextColor(0);
    //     $pdf->SetFont('');
    //     $fill = false;
    //     $opd_medicine_get_qry = 'SELECT mn.medicine_name_details_name as mname,md.medicinedosage_name as dosagename,pm.pom_medicine_stock as stock,pm.pom_medicine_days as days,pm.pom_unit as unit FROM hp_provied_opd_patient_medicine as pm LEFT JOIN hp_medicine_name    as mn ON mn.medicine_name_details_id_pk = pm.pom_medicine_name LEFT JOIN hp_medicinedosage    as md ON md.medicinedosage_id    = pm.pom_medicine_dosage WHERE  pm.pom_opd_no="'.$opd_no.'" and pm.pom_visitnumberoftime="'.$opd_visitnumberoftime.'" order by pm.pom_id desc';
    //     $opd_medicine_get = $db->selectAll($opd_medicine_get_qry);
        
    //     if(!empty($opd_medicine_get)){
    //             $html =' Medicine Name'.str_repeat(' ', 15).' Dosage'.str_repeat(' ', 15).'  Day '."\r\n";
    //             foreach ($opd_medicine_get as $mvalue) {
    //                 $html .= $mvalue['mname'].str_repeat(' ', 15).$mvalue['dosagename'].str_repeat(' ', 15).$mvalue['days']."\r\n";
    //             }
    //     }
    //     $table = array(array(date('d-m-Y',strtotime($opd_date)), $opd_symptoms,$html));
    //     $widths = array(25,65,100);
    //     $lineheight = 8;
    //     $pdf->plot_table($widths, $lineheight, $table);
    //     $pdf->Cell(190,1,'',1,0,'C',TRUE);       
    //     $pdf->Output();
    // }
    // if ($opd_visitnumberoftime=='6'){
    //     $pdf->AliasNbPages();
    //     $pdf->AddPage();
    //     $pdf->SetFont('times','B',12);
    //     $pdf->Cell(190,88,'',0,0,'C',false);
    //     $pdf->ln();
    //     $pdf->SetFont('times','B',12);
    //     $pdf->SetFillColor(32, 54, 78,1);
    //     $pdf->SetTextColor(240,245,251,1);
    //     $pdf->Cell(25,7,'Date',1,0,'C',true);
    //     $pdf->Cell(65,7,'SYMPTOMS CHANGES',1,0,'C',true);
    //     $pdf->Cell(100,7,'Remeady',1,0,'C',true);
    //     $pdf->Ln();
    //     $pdf->SetFillColor(224,235,255);
    //     $pdf->SetTextColor(0);
    //     $pdf->SetFont('');
    //     $fill = false;
    //     $opd_medicine_get_qry = 'SELECT mn.medicine_name_details_name as mname,md.medicinedosage_name as dosagename,pm.pom_medicine_stock as stock,pm.pom_medicine_days as days,pm.pom_unit as unit FROM hp_provied_opd_patient_medicine as pm LEFT JOIN hp_medicine_name    as mn ON mn.medicine_name_details_id_pk = pm.pom_medicine_name LEFT JOIN hp_medicinedosage    as md ON md.medicinedosage_id    = pm.pom_medicine_dosage WHERE  pm.pom_opd_no="'.$opd_no.'" and pm.pom_visitnumberoftime="'.$opd_visitnumberoftime.'" order by pm.pom_id desc';
    //     $opd_medicine_get = $db->selectAll($opd_medicine_get_qry);
    //     $html='';
    //     if(!empty($opd_medicine_get)){
    //             $html =' Medicine Name'.str_repeat(' ', 15).' Dosage'.str_repeat(' ', 15).'  Day '."\r\n";
    //             foreach ($opd_medicine_get as $mvalue) {
    //                 $html .= $mvalue['mname'].str_repeat(' ', 15).$mvalue['dosagename'].str_repeat(' ', 15).$mvalue['days']."\r\n";
    //             }
    //     }
    //     $table = array(array(date('d-m-Y',strtotime($opd_date)), $opd_symptoms,$html));
    //     $widths = array(25,65,100);
    //     $lineheight = 8;
    //     $pdf->plot_table($widths, $lineheight, $table);
    //     $pdf->Cell(190,1,'',1,0,'C',TRUE);       
    //     $pdf->Output();
       
    // }
    // if ($opd_visitnumberoftime=='7'){
    //     $pdf->AliasNbPages();
    //     $pdf->AddPage();
    //     $pdf->SetFont('times','B',12);
    //     $pdf->Cell(190,88,'',0,0,'C',false);
    //     $pdf->ln();
    //     $pdf->Cell(190,88,'',0,0,'C',false);
    //     $pdf->ln();
    //     $pdf->SetFont('times','B',12);
    //     $pdf->SetFillColor(32, 54, 78,1);
    //     $pdf->SetTextColor(240,245,251,1);
    //     $pdf->Cell(25,7,'Date',1,0,'C',true);
    //     $pdf->Cell(65,7,'SYMPTOMS CHANGES',1,0,'C',true);
    //     $pdf->Cell(100,7,'Remeady',1,0,'C',true);
    //     $pdf->Ln();
    //     $pdf->SetFillColor(224,235,255);
    //     $pdf->SetTextColor(0);
    //     $pdf->SetFont('');
    //     $fill = false;
    //     $opd_medicine_get_qry = 'SELECT mn.medicine_name_details_name as mname,md.medicinedosage_name as dosagename,pm.pom_medicine_stock as stock,pm.pom_medicine_days as days,pm.pom_unit as unit FROM hp_provied_opd_patient_medicine as pm LEFT JOIN hp_medicine_name    as mn ON mn.medicine_name_details_id_pk = pm.pom_medicine_name LEFT JOIN hp_medicinedosage    as md ON md.medicinedosage_id    = pm.pom_medicine_dosage WHERE  pm.pom_opd_no="'.$opd_no.'" and pm.pom_visitnumberoftime="'.$opd_visitnumberoftime.'" order by pm.pom_id desc';
    //     $opd_medicine_get = $db->selectAll($opd_medicine_get_qry);
    //     $html='';
    //     if(!empty($opd_medicine_get)){
    //             $html =' Medicine Name'.str_repeat(' ', 15).' Dosage'.str_repeat(' ', 15).'  Day '."\r\n";
    //             foreach ($opd_medicine_get as $mvalue) {
    //                 $html .= $mvalue['mname'].str_repeat(' ', 15).$mvalue['dosagename'].str_repeat(' ', 15).$mvalue['days']."\r\n";
    //             }
    //     }
    //     $table = array(array(date('d-m-Y',strtotime($opd_date)), $opd_symptoms,$html));
    //     $widths = array(25,65,100);
    //     $lineheight = 8;
    //     $pdf->plot_table($widths, $lineheight, $table);
    //     $pdf->Cell(190,1,'',1,0,'C',TRUE);       
    //     $pdf->Output();
       
    // }
    // if($opd_visitnumberoftime=='8'){
    //    $pdf->AliasNbPages();
    //    $pdf->AddPage();
    //    $pdf->SetFont('times','B',12);
    //    $pdf->SetFillColor(32, 54, 78,1);
    //    $pdf->SetTextColor(240,245,251,1);
    //     $pdf->Cell(25,7,'Date',1,0,'C',true);
    //     $pdf->Cell(65,7,'SYMPTOMS CHANGES',1,0,'C',true);
    //     $pdf->Cell(100,7,'Remeady',1,0,'C',true);
    //     $pdf->Ln();
    //     $pdf->SetFillColor(224,235,255);
    //     $pdf->SetTextColor(0);
    //     $pdf->SetFont('');
    //     $fill = false;
    //     $opd_medicine_get_qry = 'SELECT mn.medicine_name_details_name as mname,md.medicinedosage_name as dosagename,pm.pom_medicine_stock as stock,pm.pom_medicine_days as days,pm.pom_unit as unit FROM hp_provied_opd_patient_medicine as pm LEFT JOIN hp_medicine_name    as mn ON mn.medicine_name_details_id_pk = pm.pom_medicine_name LEFT JOIN hp_medicinedosage    as md ON md.medicinedosage_id    = pm.pom_medicine_dosage WHERE  pm.pom_opd_no="'.$opd_no.'" and pm.pom_visitnumberoftime="'.$opd_visitnumberoftime.'" order by pm.pom_id desc';
    //     $opd_medicine_get = $db->selectAll($opd_medicine_get_qry);
        
    //     if(!empty($opd_medicine_get)){
    //             $html =' Medicine Name'.str_repeat(' ', 15).' Dosage'.str_repeat(' ', 15).'  Day '."\r\n";
    //             foreach ($opd_medicine_get as $mvalue) {
    //                 $html .= $mvalue['mname'].str_repeat(' ', 15).$mvalue['dosagename'].str_repeat(' ', 15).$mvalue['days']."\r\n";
    //             }
    //     }
    //     $table = array(array(date('d-m-Y',strtotime($opd_date)), $opd_symptoms,$html));
    //     $widths = array(25,65,100);
    //     $lineheight = 8;
    //     $pdf->plot_table($widths, $lineheight, $table);
    //     $pdf->Cell(190,1,'',1,0,'C',TRUE);       
    //     $pdf->Output();
    // }
    // if ($opd_visitnumberoftime=='9'){
    //     $pdf->AliasNbPages();
    //     $pdf->AddPage();
    //     $pdf->SetFont('times','B',12);
    //     $pdf->Cell(190,88,'',0,0,'C',false);
    //     $pdf->ln();
    //     $pdf->SetFont('times','B',12);
    //     $pdf->SetFillColor(32, 54, 78,1);
    //     $pdf->SetTextColor(240,245,251,1);
    //     $pdf->Cell(25,7,'Date',1,0,'C',true);
    //     $pdf->Cell(65,7,'SYMPTOMS CHANGES',1,0,'C',true);
    //     $pdf->Cell(100,7,'Remeady',1,0,'C',true);
    //     $pdf->Ln();
    //     $pdf->SetFillColor(224,235,255);
    //     $pdf->SetTextColor(0);
    //     $pdf->SetFont('');
    //     $fill = false;
    //     $opd_medicine_get_qry = 'SELECT mn.medicine_name_details_name as mname,md.medicinedosage_name as dosagename,pm.pom_medicine_stock as stock,pm.pom_medicine_days as days,pm.pom_unit as unit FROM hp_provied_opd_patient_medicine as pm LEFT JOIN hp_medicine_name    as mn ON mn.medicine_name_details_id_pk = pm.pom_medicine_name LEFT JOIN hp_medicinedosage    as md ON md.medicinedosage_id    = pm.pom_medicine_dosage WHERE  pm.pom_opd_no="'.$opd_no.'" and pm.pom_visitnumberoftime="'.$opd_visitnumberoftime.'" order by pm.pom_id desc';
    //     $opd_medicine_get = $db->selectAll($opd_medicine_get_qry);
    //     $html='';
    //     if(!empty($opd_medicine_get)){
    //             $html =' Medicine Name'.str_repeat(' ', 15).' Dosage'.str_repeat(' ', 15).'  Day '."\r\n";
    //             foreach ($opd_medicine_get as $mvalue) {
    //                 $html .= $mvalue['mname'].str_repeat(' ', 15).$mvalue['dosagename'].str_repeat(' ', 15).$mvalue['days']."\r\n";
    //             }
    //     }
    //     $table = array(array(date('d-m-Y',strtotime($opd_date)), $opd_symptoms,$html));
    //     $widths = array(25,65,100);
    //     $lineheight = 8;
    //     $pdf->plot_table($widths, $lineheight, $table);
    //     $pdf->Cell(190,1,'',1,0,'C',TRUE);       
    //     $pdf->Output();
       
    // }
    // if ($opd_visitnumberoftime=='10'){
    //     $pdf->AliasNbPages();
    //     $pdf->AddPage();
    //     $pdf->SetFont('times','B',12);
    //     $pdf->Cell(190,88,'',0,0,'C',false);
    //     $pdf->ln();
    //     $pdf->Cell(190,88,'',0,0,'C',false);
    //     $pdf->ln();
    //     $pdf->SetFont('times','B',12);
    //     $pdf->SetFillColor(32, 54, 78,1);
    //     $pdf->SetTextColor(240,245,251,1);
    //     $pdf->Cell(25,7,'Date',1,0,'C',true);
    //     $pdf->Cell(65,7,'SYMPTOMS CHANGES',1,0,'C',true);
    //     $pdf->Cell(100,7,'Remeady',1,0,'C',true);
    //     $pdf->Ln();
    //     $pdf->SetFillColor(224,235,255);
    //     $pdf->SetTextColor(0);
    //     $pdf->SetFont('');
    //     $fill = false;
    //     $opd_medicine_get_qry = 'SELECT mn.medicine_name_details_name as mname,md.medicinedosage_name as dosagename,pm.pom_medicine_stock as stock,pm.pom_medicine_days as days,pm.pom_unit as unit FROM hp_provied_opd_patient_medicine as pm LEFT JOIN hp_medicine_name    as mn ON mn.medicine_name_details_id_pk = pm.pom_medicine_name LEFT JOIN hp_medicinedosage    as md ON md.medicinedosage_id    = pm.pom_medicine_dosage WHERE  pm.pom_opd_no="'.$opd_no.'" and pm.pom_visitnumberoftime="'.$opd_visitnumberoftime.'" order by pm.pom_id desc';
    //     $opd_medicine_get = $db->selectAll($opd_medicine_get_qry);
    //     $html='';
    //     if(!empty($opd_medicine_get)){
    //             $html =' Medicine Name'.str_repeat(' ', 15).' Dosage'.str_repeat(' ', 15).'  Day '."\r\n";
    //             foreach ($opd_medicine_get as $mvalue) {
    //                 $html .= $mvalue['mname'].str_repeat(' ', 15).$mvalue['dosagename'].str_repeat(' ', 15).$mvalue['days']."\r\n";
    //             }
    //     }
    //     $table = array(array(date('d-m-Y',strtotime($opd_date)), $opd_symptoms,$html));
    //     $widths = array(25,65,100);
    //     $lineheight = 8;
    //     $pdf->plot_table($widths, $lineheight, $table);
    //     $pdf->Cell(190,1,'',1,0,'C',TRUE);       
    //     $pdf->Output();
       
    // }else{
    //     $pdf->AliasNbPages();
    //     $pdf->AddPage();
    //     $pdf->SetFont('times','B',12);
    //     $pdf->SetFillColor(32, 54, 78,1);
    //     $pdf->SetTextColor(240,245,251,1);
    //     $pdf->Cell(25,7,'Date',1,0,'C',true);
    //     $pdf->Cell(65,7,'SYMPTOMS CHANGES',1,0,'C',true);
    //     $pdf->Cell(100,7,'Remeady',1,0,'C',true);
    //     $pdf->Ln();
    //     $pdf->SetFillColor(224,235,255);
    //     $pdf->SetTextColor(0);
    //     $pdf->SetFont('');
    //     $fill = false;
    //     $opd_medicine_get_qry = 'SELECT mn.medicine_name_details_name as mname,md.medicinedosage_name as dosagename,pm.pom_medicine_stock as stock,pm.pom_medicine_days as days,pm.pom_unit as unit FROM hp_provied_opd_patient_medicine as pm LEFT JOIN hp_medicine_name    as mn ON mn.medicine_name_details_id_pk = pm.pom_medicine_name LEFT JOIN hp_medicinedosage    as md ON md.medicinedosage_id    = pm.pom_medicine_dosage WHERE  pm.pom_opd_no="'.$opd_no.'" and pm.pom_visitnumberoftime="'.$opd_visitnumberoftime.'" order by pm.pom_id desc';
    //     $opd_medicine_get = $db->selectAll($opd_medicine_get_qry);
        
    //     if(!empty($opd_medicine_get)){
    //             $html =' Medicine Name'.str_repeat(' ', 15).' Dosage'.str_repeat(' ', 15).'  Day '."\r\n";
    //             foreach ($opd_medicine_get as $mvalue) {
    //                 $html .= $mvalue['mname'].str_repeat(' ', 15).$mvalue['dosagename'].str_repeat(' ', 15).$mvalue['days']."\r\n";
    //             }
    //     }
    //     $table = array(array(date('d-m-Y',strtotime($opd_date)), $opd_symptoms,$html));
    //     $widths = array(25,65,100);
    //     $lineheight = 8;
    //     $pdf->plot_table($widths, $lineheight, $table);
    //     $pdf->Cell(190,1,'',1,0,'C',TRUE);       
    //     $pdf->Output();
       
    // }
}
$pdf->lastPage();
$pdf->Output('opdcase.pdf', 'I');
?>