<?php 
include('../config/config.php');
include("../classes/classShift.php");
include("../classes/classDoctor.php");
include("../classes/classDiagnostic.php");
include('../classes/classPatient.php');
include("../classes/classImages.php");
include('../classes/classTransaction.php');
include('../classes/classVisits.php');


if(isset($_GET['visitid'])&&$_GET['visitid']!='')
{
	$_SESSION['temp']['visit_id'] = base64_decode($_GET['visitid']);
}
if(isset($_GET['patientid'])&&$_GET['patientid']!='')
{
	$_SESSION['temp']['patient_id'] = base64_decode($_GET['patientid']);
}
if(isset($_GET['doctorid'])&&$_GET['doctorid']!='')
{
	$_SESSION['temp']['doctorid'] = base64_decode($_GET['doctorid']);
}


if(isset($_SESSION['temp']['doctorid'])&&$_SESSION['temp']['doctorid']!='')
{
	$doctor_id = $_SESSION['temp']['doctorid'];
}
if(isset($_SESSION['temp']['patient_id'])&&$_SESSION['temp']['patient_id']!='')
{
	$patient_id = $_SESSION['temp']['patient_id'];
}
if(isset($_SESSION['temp']['visit_id'])&&$_SESSION['temp']['visit_id']!='')
{
	$visit_id = $_SESSION['temp']['visit_id'];
}




///////////// retrieve things ////////////////////////////////////////

try
{
	$retrieveVisitPrecOb = new classVisits;
	$retrieveVisitPrecOb->setVisitID($visit_id);
	$visit_array = $retrieveVisitPrecOb->retrieveVisitByVisitID();
	
	$diagInvOb = new classDiagnostic;
	$inv_data = $diagInvOb->retrieveInvoiceDetailByVisitID($visit_id);
	
	$diagInvOb->setDiagInvoiceID($inv_data[0]['diaginvoice_id']);
	$invoice_items_array = $diagInvOb->retrieveInvoiceItemsDetail();
	
	///////////// retrieve patient single data ///////////////////////////////
	
	$retrievePatientOb = new classPatient;
	$retrievePatientOb->setPatientAutoID($patient_id);
	$patient_single_detail = $retrievePatientOb->retrievePatientByPatientID();
	
	$patient_age = $retrievePatientOb->age_from_dob($patient_single_detail[0]['dob']);
	
	
///////////// retrieve doctor Detail ////////////////////////////////////////

try
{
	$doctorOb = new classDoctor;
	$doctorOb->setDoctorID($doctor_id);
	$doctor_detail = $doctorOb->retrieveDoctorByDoctorID();
	
	$doctor_name = $doctor_detail[0]['title'].'. '.$doctor_detail[0]['doc_fname'].' '.$doctor_detail[0]['doc_lname'];
	
	$doctor_acc_id = $doctor_detail[0]['account_id'];
	
}
catch (MyException $e)
{
	$error_message = $e->getUserMsg();
}	

	///////////// retrieve patient image ///////////////////////////////
	
	$imageRetrieveOb = new classImages;
	$imageRetrieveOb->setPatientAutoID($patient_id);
	$image_id = $imageRetrieveOb->fetchImageOfPatient();
	
}
catch (MyException $e)
{
	$error_message = $e->getUserMsg();
}	

try
{
	$retrieveOb = new classVisits;
	$medicine_array = $retrieveOb->retrieveMedicines();
	$labtest_array = $retrieveOb->retrieveLabTests();
	$procedure_array = $retrieveOb->retrieveProcedures();
	
}
catch (MyException $e)
{
	$error_message = $e->getUserMsg();
}	

/*echo '<pre>';
print_r($_POST);
echo '</pre>';*/

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/print.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

    <link rel="shortcut icon" href="../images/favicon.png">
    <title>Med2TEC Hospital Management Information System</title> 
    <link href="../css/print.css" rel="stylesheet">
    <link href="../datepicker/jquery-ui.css" rel="stylesheet" >  
    <script type="text/javascript" src="../datepicker/jquery-1.9.1.js"></script>
	<script type="text/javascript" src="../datepicker/jquery-ui.js"></script> 
</head>

<body> 
<div align="right"> 
 <SCRIPT LANGUAGE="JavaScript">  
if (window.print) {
document.write('<form class="no-print"><input type=button name=print value="Print" onClick="window.print()"></form>');
}
</script></div>

<section class="wrapper">
<div style="background:#FFF; padding:0px 0px 0; height:auto;">
  <table cellspacing="0" cellpadding="0" width="100%" border="0" style="font-size:11px;">
    <tbody>
      <tr>
        <td align="left" style="background:#fff;"><img alt="" src="../images/org_print_logos/<?php echo $_SESSION['security']['org_id']?>.png" style="width:100%;"></td>
      </tr>
    </tbody>
  </table>
  
</br>

</div>

<div class="row">
          <section class="panel">
            <header class="panel-heading">
              <h2><!-- InstanceBeginEditable name="title" -->LAB PRESCRIPTION<!-- InstanceEndEditable --></h2>
            </header>

  <br />
  
<!-- InstanceBeginEditable name="main" -->
  <!-- page start-->
        <div class="row">
        
        <header class="panel-heading">
            <h1><?php echo $doctor_name;?></h1>
            317 A-One Township Lahore<br />
            Ph. 042-35151666
        </header>
        
        <p>
        <?php
        if(isset($error_message)&&$error_message!='')
        {
			?>
			<span class="message_red"><?php echo $error_message;?></span>
			<?php
        }
        ?>
        </p>
        
        <table width="97%" border="0" cellspacing="1" cellpadding="0" style="border-bottom:1px solid #999;">
            <tr>
                <td width="70%"></td>
                <td width="30%" align="right"><img src="../images/iconrx.png" widtd="80" height="80" /></td>
            </tr>
        </table>
        
        <br />
        
        <table width="97%" border="0" cellspacing="5" cellpadding="5" style="border-bottom:1px solid #999;">
        
            <tr>
            	<td width="20%" align="right">Patient ID:</td>
            	<td width="30%"><?php echo $patient_single_detail[0]['patient_id']; ?></td>
            	<!-- <td width="20%" align="right">PR#:</td>
            	<td width="30%"></td>-->
            </tr>
            
            <tr>
            	<td align="right">Patient Name:</td>
            	<td><?php echo $patient_single_detail[0]['patient_fname'].' '.$patient_single_detail[0]['patient_lname'];?></td>
            	<td align="right">Date:</td>
            	<td><?php echo date('d M Y',$visit_array[0]['visit_date']); ?></td>
            </tr>
            
            <tr>
            	<td align="right">Gender:</td>
            	<td><?php echo $patient_single_detail[0]['gender'];?></td>
            	<td align="right">Visit ID:</td>
           		<td><?php echo $visit_id;?></td>
            </tr>
            
            <tr>
            	<td align="right">Age:</td>
            	<td><?php echo $patient_age?></td>
            	<td align="right">Visit Type:</td>
            	<td>OPD</td>
            </tr>
            
        </table>
        
        <br />
        
        <table width="80%" align="center" border="0" cellspacing="5" cellpadding="5">
        
        	<tr>
            	<td width="40%" align="left"><strong>Tests:</strong></td>
            	<td width="30%" align="left"><strong>Results:</strong></td>
            	<td width="30%" align="left"><strong>Normal Values:</strong></td>
            </tr>
        
         	<?php
			for($prm=0;$prm<count($invoice_items_array);$prm++)
			{
				if($invoice_items_array[$prm]['diagnosis_type']=='labtest')
				{	
					$retreiveOb = new classDiagnostic;
					$retreiveOb->setLabTestID($invoice_items_array[$prm]['diagnosis_id']);
					$labtest_info = $retreiveOb->retrieveLabTestsByLabTestID();
					
					$test_name = $labtest_info[0]['labtest_name'];
					$normal_value = $labtest_info[0]['normal_value'];
					$diagnosis_result = $invoice_items_array[$prm]['diagnosis_result'];
					?>
					<tr>
            
                        <td align="left" valign="top"><?php  echo $test_name;?></td>
                
                        <td valign="top"><h4><?php  echo $normal_value;?></h4></td>
                        
                        <td align="left" valign="top"><?php  echo $diagnosis_result;?></td>
                
                    </tr>
                    <?php
                    
                    
					
				}
			}
			?>
        	
        
        </table>       
        
        
        </div>
        <!-- page end-->
        
        <p align="center" style="font-size:12px; font-family:Arial, Helvetica, sans-serif; margin-top:260px;">
        <strong>(Not Valid for Court or any Legal Purpose)</strong><br />
        For Appointment call at 042-35151666 (bring your Patient ID Card)
        </p>
        
<!-- InstanceEndEditable -->
</section>
</div>

<!--<p align="center" style="font-size:12px; font-family:Arial, Helvetica, sans-serif; margin-top:260px;"><strong><!--317 A-1, Nursery Stop, Township, Lahore. 
Ph: 042-35151666</strong><br />
For Appointment call at 042-35151666 (bring your Patient ID Card) </p>-->

   <div class="sidepop" style="float:right;">
    <div class="sidepopbutton stemp"><div style="color: rgb(0, 0, 0); text-align: right; font-size: 10px; margin-top: 4px; position: absolute; right: 180px;">© Software by Softusion Inc. 0322 6155 219</div>   
    </div>
</div>

<!--<div class="sidepop" style="float:right;">
    <div class="sidepopbutton stemp"><div style="color:#000; text-align:right; font-size:9px;">© Software designed by Softusion Inc. Contact us at 0322 6155 219</div>   
    </div>
</div>-->


          
</body>
<!-- InstanceEnd --></html>