<?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['diaginvoice_id'])&&$_GET['diaginvoice_id']!='')
{
	$_SESSION['temp']['diaginvoice_id'] = base64_decode($_GET['diaginvoice_id']);
}
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']['diaginvoice_id'])&&$_SESSION['temp']['diaginvoice_id']!='')
{
	$diaginvoice_id = $_SESSION['temp']['diaginvoice_id'];
}
if(isset($_SESSION['temp']['patient_id'])&&$_SESSION['temp']['patient_id']!='')
{
	$patient_id = $_SESSION['temp']['patient_id'];
}
if(isset($_SESSION['temp']['doctorid'])&&$_SESSION['temp']['doctorid']!='')
{
	$doctor_id = $_SESSION['temp']['doctorid'];
}





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

try
{
	
	
	$diagInvOb = new classDiagnostic;
	$diagInvOb->setDiagInvoiceID($diaginvoice_id);
	$invoice_array = $diagInvOb->retrieveInvoiceDetail();
	$invoice_items_array = $diagInvOb->retrieveInvoiceItemsDetail();
	$bcm_detail = $diagInvOb->retrieveBloodCrossMatchDetailByInvoiceID();
	
	$retreiveTestOb = new classDiagnostic;
	$retreiveTestOb->setLabTestID($invoice_items_array[0]['diagnosis_id']);
	$labtest_info = $retreiveTestOb->retrieveLabTestsByLabTestID();
	
	
	if($invoice_array[0]['visit_id']!=0)
	{
		$visitOb = new classVisits;
		$visitOb->setVisitID($labtest_array[$v]['visit_id']);
		$visit_info = $visitOb->retrieveVisitByVisitID();
		
		############# get doctor data ##########################
		$doctorOb = new classDoctor;
		$doctorOb->setDoctorID($visit_info[0]['doctor_id']);
		$doctor_detail = $doctorOb->retrieveDoctorByDoctorID();
		$referred_by = $doctor_detail[0]['title'].'. '.$doctor_detail[0]['doc_fname'].' '.$doctor_detail[0]['doc_lname'];
	}
	else
	{
		$referred_by = $invoice_array[0]['referred_by'];
	}
	
	///////////// retrieve patient single data ///////////////////////////////
	if($patient_id!=0)
	{
		$retrievePatientOb = new classPatient;
		$retrievePatientOb->setPatientAutoID($patient_id);
		$patient_single_detail = $retrievePatientOb->retrievePatientByPatientID();
	}
	else
	{
		
		$patient_name = 'Outdoor';
		$patient_gender = '';
		$patient_age = '';
	}
	
	
///////////// retrieve patient image ///////////////////////////////
	
	$imageRetrieveOb = new classImages;
	$imageRetrieveOb->setPatientAutoID($patient_id);
	$image_id = $imageRetrieveOb->fetchImageOfPatient();
	
}
catch (MyException $e)
{
	$error_message = $e->getUserMsg();
}	



/*echo '<pre>';
print_r($invoice_items_array);
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">
<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 rel="stylesheet" href="../datepicker/jquery-ui.css">  
    <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;"></td>
      </tr>
    </tbody>
  </table>
  
</br>

</div>

<div class="row">
          <section class="panel">
            <header class="panel-heading">
              <h2>&nbsp;</h2>
            </header>

  <br />
<!-- page start-->
        <div class="row">
        
        <header class="panel-heading"></header>
        
        <p>
        <?php
        if(isset($error_message)&&$error_message!='')
        {
			?>
			<span class="message_red"><?php echo $error_message;?></span>
			<?php
        }
        ?>
        </p>
        
        
		<table width="100%" border="0" cellspacing="2" cellpadding="2" style="border-top:1px solid #999; border-bottom:1px solid #999; font-size:12px;">
        	<tr>
        <td width="25%">Patient ID:</td>
        <td width="37%"><?php  if(isset($patient_single_detail[0]['patient_auto_id'])){echo $patient_single_detail[0]['patient_auto_id'];}?></td>
        <td width="18%">Date:</td>
        <td width="20%"><?php echo date('d M Y h:i:s A',$invoice_array[0]['diaginvoice_date']);?></td>
        </tr>
        	<tr>
        <td>Patient Name:</td>
        <td>
        <?php if(isset($patient_single_detail[0]['patient_fname'])){echo strtoupper($patient_single_detail[0]['patient_fname'].' '.$patient_single_detail[0]['patient_lname']);}else{echo 'Outdoor';}?>
        </td>
        <td>Invoice #:</td>
        <td><?php echo $diaginvoice_id;?></td>
        </tr>
        	<tr>
        <td>s/d/w of:</td>
        <td>
        <?php if(isset($patient_single_detail[0]['relationship_name'])){echo strtoupper($patient_single_detail[0]['relationship_name']);}?>
       </td>
        <td>Referred by:</td>
        <td><?php echo strtoupper($referred_by);?></td>
        </tr>
        	<tr>
        <td>Phone:</td>
        <td>
        <?php if(isset($patient_single_detail[0]['phone'])){echo $patient_single_detail[0]['phone'];}?>
        </td>
        <td>Address:</td>
        <td>
        <?php if(isset($patient_single_detail[0]['address'])){echo strtoupper($patient_single_detail[0]['address']);}?>
       </td>
        </tr>
        	<tr>
        <td>Gender:</td>
        <td>
        <?php if(isset($patient_single_detail[0]['gender'])){echo strtoupper($patient_single_detail[0]['gender']);}?>
       </td>
        <td>Age;</td>
        <td><?php if(isset($patient_single_detail[0]['age'])){echo $patient_single_detail[0]['age'].' years';}?></td>
        </tr>
        
        </table>
        
        <br />
        
        <table width="100%" align="center" border="0" cellspacing="0" cellpadding="2" style="padding:2px; border-bottom:1px solid #999;">
        
            <tr bgcolor="#ccc">
            	<td width="62%" height="37" align="left"><strong> Doner's Name:</strong></td>
            	<td width="38%" align="left"><strong><?php echo ucwords($bcm_detail[0]['donor_name']);?></strong></td>
            </tr>
        
         	<tr>
            	<td><strong>Blood Group: </strong></td>
            	<td><?php echo $bcm_detail[0]['blood_group'];?></td>
            </tr>
            <?php
			if($labtest_info[0]['labtest_name']=='Blood Cross Matching')
			{
				?>
				<tr>
					<td align="left"><strong>Hepatitis-B Antigen:</strong></td>
					<td align="left"><?php echo $bcm_detail[0]['hb_antigen'];?></td>
				</tr>
				
				<tr>
					<td align="left"><strong>Hepatitis-C Antigen:</strong></td>
					<td align="left"><?php echo $bcm_detail[0]['hc_anitgen'];?></td>
				</tr>
				
				<tr>
					<td align="left"><strong>H.I.V.</strong></td>
					<td align="left"><?php echo $bcm_detail[0]['hiv'];?></td>
				</tr>
				
				<tr>
					<td align="left"><strong>MP:</strong></td>
					<td align="left"><?php echo $bcm_detail[0]['mp'];?></td>
				</tr>
				
				<tr>
					<td align="left"><strong>VDRL:</strong></td>
					<td align="left"><?php echo $bcm_detail[0]['vdrl'];?></td>
				</tr>
				<?php
			}
			?>
        </table> 
        
        <br />
        
		<table width="100%" align="center" border="0" cellspacing="0" cellpadding="2" style="padding:2px; border-bottom:1px solid #999;">
        
            <tr bgcolor="#ccc">
                <td width="62%" height="37" align="left"><strong> Recipient's Name:</strong></td>
                <td width="38%" align="left"><strong><?php echo ucwords($bcm_detail[0]['receipient_name']);?></strong></td>
            </tr>
            
            
            <tr>
                <td><strong>Blood Group: </strong></td>
                <td><?php echo $bcm_detail[0]['recipient_blood_group'];?></td>
            </tr>
				
            
        </table> 
        
        <br />
        
		<table width="100%" align="center" border="0" cellspacing="0" cellpadding="2" style="padding:2px; border-bottom:1px solid #999;">
        
         
        <tr>
            <td width="62%">Donor's red blood cells cross-matched with recepient's serum and found</td>
            <td width="38%"><?php echo $bcm_detail[0]['remarks'];?></td>
        </tr>
					
        </table>       
        
        </div>
        <!-- page end-->
</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>-->


<style>
#block{
    width:500px;
   /* height:500px;*/
    display:block;
    margin:auto;
  /*  border: 1px solid #000;*/
    position:relative;
	float:right;
    }

#text {
    padding:0;
    margin:0;
    position:fixed;
    right:-500px;
    font-size:9px;
    top:960px;
    -webkit-transform: rotate(-90deg);
    -moz-transform: rotate(-90deg);
    -ms-transform: rotate(-90deg);
    -o-transform: rotate(-90deg);
}
</style>
<div id="block">
<p id="text">© Software designed by Softusion Inc. Contact us at 0322 6155 219</p>
</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>
</html>