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

unset($_SESSION['print']);
################################################################################
#########################Pagination Starts here. {########################
################################################################################

$countDiagTestOb = new classDiagnostic;
$countDiagTestOb->setLocationID($_SESSION['security']['location_id']);
$countDiagTestOb->setDiagnosisType('labtest');
$count = $countDiagTestOb->countPaidInvoiceItemsDetailByLocationIDAndType();

$array['item_count'] = $count;
if(isset($_GET['page']) && isset($_GET['items']))
{
	if($array['item_count'] > $_GET['items'])
	{
		$array['pages'] = ceil($array['item_count']/$_GET['items']);
		if($_GET['page'] >$array['pages'])
		{
			$_GET['page'] = 1;
		}
		$array['current_page'] = $_GET['page'];
		if($_GET['page'] > 1)
		{
			$starting_record = $_GET['items']*($_GET['page']-1);
			$ending_record = $_GET['items'];
			$array['limit'] = $starting_record . "," . $ending_record;
			$limit = $array['limit'];
		}
		else
		{
			$limit = $_GET['items'];
		}
	}
	else
	{
		$array['current_page'] = $_GET['current_page'] = 1;
		$array['pages'] = 1;
		$array['limit'] = $_GET['items'];
		$limit = $array['limit'];
	}
}
else
{
	if($array['item_count'] > 30)
	{
		$array['pages'] = ceil($array['item_count']/30);
	}
	else
	{
		$array['pages'] = 1;
	}
	$array['current_page'] = 1;
	$array['limit'] = 30;
	$limit = $array['limit'];
}

$_SESSION['pagination']['item_count']=$array['item_count'];
$_SESSION['pagination']['pages']=$array['pages'];
$_SESSION['pagination']['current_page']=$array['current_page'];
$_SESSION['pagination']['limit']=$limit;

################################################################################
######################### Pagination Ends here. }##########################
################################################################################

################## Search Patients Start ####################################
try
{
	if(isset($_POST['search'])&&$_POST['search']=='Search')
	{
		$_SESSION['print']['search'] = $_POST['search'];
		$_SESSION['print']['by_id'] = $_POST['by_id'];
		$_SESSION['print']['by_name'] = $_POST['by_name'];
		$_SESSION['print']['by_phone'] = $_POST['by_phone'];
		
		$retrievePatientOb = new classPatient;
		$patients_array = $retrievePatientOb->searchPatient($_POST['by_id'],$_POST['by_name'],$_POST['by_phone'],$_SESSION['security']['location_id']);
		
		
		
		if(isset($patients_array[0]['patient_auto_id']))
		{
			for($p=0;$p<count($patients_array);$p++)
			{
				$diagTestOb = new classDiagnostic;
				$diagTestOb->setLocationID($_SESSION['security']['location_id']);
				$diagTestOb->setDiagnosisType('labtest');
				$diagTestOb->setPatientID($patients_array[$p]['patient_auto_id']);
				$patient_single_array = $diagTestOb->retrievePaidInvoiceItemsDetailByLocationIDPatientIDAndType();
				if($patient_single_array[0]!='')
				{
					for($ps=0;$ps<count($patient_single_array);$ps++)
					{
						$labtest_array[] = $patient_single_array[$ps];
					}
					
				}
				
			}
		}
	}
	else
	{
		$diagTestOb = new classDiagnostic;
		$diagTestOb->setLocationID($_SESSION['security']['location_id']);
		$diagTestOb->setDiagnosisType('labtest');
		$labtest_array = $diagTestOb->retrievePaidInvoiceItemsDetailByLocationIDAndType($limit);
	}
	
}
catch (MyException $e)
{
	$error_message = $e->getUserMsg();
}

try
{
	$labtestOb = new classDiagnostic;
	$labtestOb->setOrganizationID($_SESSION['security']['org_id']);
	$labtest_dropdown = $labtestOb->retrieveLabTests();
}
catch (MyException $e)
{
	$error_message = $e->getUserMsg();
}

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

exit;*/
?>
<!DOCTYPE html>
<html><!-- InstanceBegin template="/Templates/main.dwt.php" codeOutsideHTMLIsLocked="false" -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<head> 
    <link rel="shortcut icon" href="../images/favicon.png">
    <!-- InstanceBeginEditable name="doctitle" -->
    <title>Med2TEC Hospital Management Information System</title>
    <!-- InstanceEndEditable -->
    <!--Core CSS -->
    <link href="../bs3/css/bootstrap.min.css" rel="stylesheet"> 
    <link href="../css/style.css" rel="stylesheet">
    <link href="../css/style-responsive.css" rel="stylesheet"/> 
    <link href="../popUp/popUp.css" rel="stylesheet">
    <link href="../css/bootstrap-fullcalendar.css" rel="stylesheet"/> 
    
    <link href="../css/clndr.css" rel="stylesheet">
    
    <link href="../css/css/font-awesome.css" rel="stylesheet">
    
    <link href="../assets/jquery-ui/jquery-ui-1.10.1.custom.min.css" rel="stylesheet">
    <link href="../assets/jvector-map/jquery-jvectormap-1.2.2.css" rel="stylesheet">    
    <link href="../assets/jquery-multi-select/css/multi-select.css" rel="stylesheet" type="text/css">
    <!--clock css-->
    <link href="../assets/css3clock/css/style.css" rel="stylesheet"> 
    <!--Morris Chart CSS -->
    <link rel="stylesheet" href="../assets/morris-chart/morris.css">
    <!-- Custom styles for this template -->
   
    <link href="../datepicker/jquery-ui.css" rel="stylesheet" >   
<!-- InstanceBeginEditable name="head" -->
<!-- InstanceEndEditable -->
</head>
<body>

<section id="container">
    <!--header start-->
    <header class="header fixed-top clearfix">
        <!--logo start-->
        <div class="brand">

            <a href="home.php" class="logo">
                <img src="../images/logo.png" alt="">
            </a>
            <div class="sidebar-toggle-box">
                <div class="fa fa-bars"></div>  
            </div>
        </div> 
        <!--logo end-->

        <div class="nav notify-row" id="top_menu" style="float: right; margin-top: 16px; margin-left: 0px; margin-right: 10px;">
            <!--  notification start -->
             <img alt="" src="../images/org_logos/<?php echo $_SESSION['security']['org_id']?>.png">
            <!--  notification end -->
        </div>
        <div class="top-nav clearfix">
            <!--search & user info start-->
            <ul class="nav pull-right top-menu">
                <li>
                    <div class="toggle-right-box"><!-- InstanceBeginEditable name="print" -->
                    <a href="javascript:Popup('printdiaglabtests.php')"><i class="fa fa-print" style="margin-left: 11px; margin-top: 11px;"></i></a>
					<!-- InstanceEndEditable --></div>
                </li>
                <!-- user login dropdown start-->
                <li class="dropdown">
                    <a data-toggle="dropdown" class="dropdown-toggle" href="#">
                        <img alt="" src="../images/avatar1_small.jpg"> 
                        <span class="username"><?php echo $username;?></span>
                        <b class="caret"></b>
                    </a>
                    <ul class="dropdown-menu extended logout">
                        <li><a href="profile.php"><i class=" fa fa-suitcase"></i>Profile</a></li>
                        <li><a href="#update_password-box" class="update_password-window"><i class="fa fa-cog"></i> Change Password</a></li>
                        <li><a href="../logout.php"><i class="fa fa-key"></i> Log Out</a></li>
                    </ul>
                </li>
                <!-- user login dropdown end -->
                <li>
                    <div class="toggle-right-box">
                        <div class="fa fa-bars"></div>
                    </div>
                </li>
            </ul>
            <!--search & user info end-->
        </div>
    </header>
    <!--header end-->
    <!--sidebar start-->
   <aside>
        <div id="sidebar" class="nav-collapse">
            <!-- sidebar menu start-->
            <ul class="sidebar-menu" id="nav-accordion">
             <?php
					  
$orgOb = new classUser;
$orgOb->retrieveOrgDataByOrgID($_SESSION['security']['org_id']);

		  if($orgOb->getDB())
		  {
				if($_SESSION['security']['userrole_id']==1||$_SESSION['security']['userrole_id']==2||$_SESSION['security']['userrole_id']==9||$_SESSION['security']['userrole_id']==100)
				{
					?>
					  	<li>
                    	<a class="active" href="db.php" style="background:#0072BC;">
                        <i class="fa fa-dashboard"></i> 
                        <span>Dashboard</span>
                    	</a>
                		</li>
					  <?php
				}
		  }
				if($_SESSION['security']['userrole_id']==1||$_SESSION['security']['userrole_id']==2||$_SESSION['security']['userrole_id']==3||$_SESSION['security']['userrole_id']==5||$_SESSION['security']['userrole_id']==9||$_SESSION['security']['userrole_id']==10||$_SESSION['security']['userrole_id']==100)
				{
					?>
					    <li class="sub-menu">
                    	<a href="dbpatient.php" style="background:#BC1C4A;">
                        <i class="fa fa-user"></i>
                        <span>Patient Registration</span>
                    	</a>
                    	</li>
					  <?php
				}
		  
		  if($orgOb->getOPD())
		  {
				if($_SESSION['security']['userrole_id']==1||$_SESSION['security']['userrole_id']==2||$_SESSION['security']['userrole_id']==3||$_SESSION['security']['userrole_id']==4||$_SESSION['security']['userrole_id']==5||$_SESSION['security']['userrole_id']==9||$_SESSION['security']['userrole_id']==100)
				{
					?>
						<li class="sub-menu">
						<a href="dbopd.php" style="background:#003366;">
						<i class="fa fa-th"></i>
						<span>Out-Patient (OPD)</span>
						</a>
						</li>
						<?php
				}
		  }
		  if($orgOb->getIPD())
		  {
			  if($_SESSION['security']['userrole_id']==1||$_SESSION['security']['userrole_id']==2||$_SESSION['security']['userrole_id']==3||$_SESSION['security']['userrole_id']==9||$_SESSION['security']['userrole_id']==6||$_SESSION['security']['userrole_id']==15||$_SESSION['security']['userrole_id']==100)
				{
			  	?>
						<li class="sub-menu">
						<a href="dbipd.php" style="background:#8EC63F;">
						<i class="fa fa-th"></i>
						<span>In-Patient (IPD)</span>
						</a>
						</li>
						<?php
				}
					
		  }
		  if($orgOb->getOT())
		  {
			  if($_SESSION['security']['userrole_id']==1||$_SESSION['security']['userrole_id']==2||$_SESSION['security']['userrole_id']==3||$_SESSION['security']['userrole_id']==9||$_SESSION['security']['userrole_id']==6||$_SESSION['security']['userrole_id']==15||$_SESSION['security']['userrole_id']==100) 
				{
			   		?>
						<li class="sub-menu">
						<a href="dbot.php" style="background:#D6502A;">
						<i class="fa fa-th"></i>
						<span>Operation Theater</span>
						</a>
						</li>
                        <?php
				}
		  }			
		  if($orgOb->getPharmacy())
		  {
				if($_SESSION['security']['userrole_id']==1||$_SESSION['security']['userrole_id']==2||$_SESSION['security']['userrole_id']==3||$_SESSION['security']['userrole_id']==6||$_SESSION['security']['userrole_id']==7||$_SESSION['security']['userrole_id']==8||$_SESSION['security']['userrole_id']==9||$_SESSION['security']['userrole_id']==100)
				{
			  		?>
						<li class="sub-menu">
						<a href="dbpharmacy.php" style="background:#00869C;">
						<i class="fa fa-th"></i>
						<span>Pharmacy</span>
						</a>
						</li>
						<?php
				}
		  }
		  if($orgOb->getDiagnostic())
		  {
				if($_SESSION['security']['userrole_id']==1||$_SESSION['security']['userrole_id']==2||$_SESSION['security']['userrole_id']==3||$_SESSION['security']['userrole_id']==14||$_SESSION['security']['userrole_id']==9||$_SESSION['security']['userrole_id']==100)
				{
			  	?>
						<li>
						<a href="dbdiagnostics.php" style="background:#380E4D;">
						<i class="fa fa-th"></i>
						<span>Diagnostics </span>
						</a>
						</li>
						<?php
				}
		  }
		  
					  ?>
						<!--<li class="sub-menu">
						<a href="dbemergency.php" style="background:#3AC7F9;">
						<i class="fa fa-tasks"></i>
						<span>Facility Management </span>
						</a>
						</li>-->
						<?php
          if($orgOb->getAdmin())
		  {
				if($_SESSION['security']['userrole_id']==1||$_SESSION['security']['userrole_id']==2||$_SESSION['security']['userrole_id']==9||$_SESSION['security']['userrole_id']==100)
				{
					?>
						<li class="sub-menu">
						<a href="dbadmin.php" style="background:#28282E;">
						<i class="fa fa-laptop"></i>
						<span>Admin Panel</span>
						</a>
						</li>
						<?php
				}
		  }
		  ?>
               
            </ul> 
            <div style="position: absolute; bottom: 2%; padding-left:10%;"><a href="http://www.softusion.com/" target="_blank"><img width="30" height="40" src="../images/SoftusionLOGO.png" alt=""><span style="font-size: 11px; float: right; margin-top: 15%;">Designed by Softusion Inc.</span></a></div><br>
            <!-- sidebar menu end-->
        </div>
    </aside>
    <!--sidebar end-->
    <!--main content start-->
	<!-- InstanceBeginEditable name="center" -->
  <section id="main-content">
    <section class="wrapper">
   	<table cellspacing="0" cellpadding="0" width="100%" border="0" style="font-size:11px;">
  <tbody>
    <tr>
      <td width="12%" align="center"><a href="dbdiagnostics.php"><img src="../images/icondb.png"></a></td>
      <td width="12%" align="center"></td>
      <td width="12%" align="center"></td>
      <td width="12%" align="center"></td>
      <td width="12%" align="center"></td>
      <td width="12%" align="center"></td>
      <td width="12%" align="center"></td>
      <td width="12%" align="center"></td>
      <td width="2%" align="center">&nbsp;</td>
    </tr>
    <tr>
      <td align="center"><a href="dbdiagnostics.php">Diagnostics</a></td>
      <td align="center"></td>
      <td align="center"></td>
      <td align="center"></td>
      <td align="center"></td>
      <td align="center"></td>
      <td align="center"></td>
      <td align="center"></td>
      <td align="center"></td>
      <td height="24" align="center">&nbsp;</td>
    </tr>
  </tbody>
</table>
	<br>
      <!-- page start-->
      <div class="row">
        <div class="col-sm-12">
          <section class="panel">
           <header class="panel-heading">
              <h2>BLOOD TEST RESULTS</h2>
            </header>
           
            <form action="" method="post">
            <table width="100%" border="0" cellpadding="1" cellspacing="0">
              <tr>
              
                <td width="10%" align="right">Search Name: </td>
                <td width="15%">
                	<input type="text" name="by_name" value="" class="form-control" aria-controls="dynamic-table">
                </td>
                
                <td width="5%" align="right">ID: </td>
                <td width="15%">
                	<input type="text" name="by_id" value="" class="form-control" aria-controls="dynamic-table">
                </td>
                
                <td width="5%" align="right">Phone: </td>
                <td width="15%">
                	<input type="text" name="by_phone" value="" class="form-control" aria-controls="dynamic-table">
                </td>
                
                <td><input name="search" type="submit" class="btn btn-success btn-sm" value="Search"/></td>
                
                <td width="5%" align="right"><a href="diaglabtests.php">View All</a></td>
                
                <td width="20%" align="right"><!--<div class="row-fluid">
                    <div class="span6">
                        <div id="dynamic-table_length" class="dataTables_length">
                        <label>
                        <select name="dynamic-table_length" size="1" class="form-control" aria-controls="dynamic-table">
                            <option value="10" selected="selected">10</option>
                            <option value="25">25</option>
                            <option value="50">50</option>
                            <option value="100">100</option>
                        </select>
                        </label>
                        </div>
                    </div>
                </div>-->
                </td>
                
                <td width="10%"><!--records per page--></td>
                
              </tr>
            </table>
            </form>
            
            <br><br><br><br>
            
            <div class="panel-body" style="padding-top: 0px; margin-top:-34px;">
              <div class="adv-table">
              
                <table  class="display table table-bordered table-striped" id="dynamic-table">
                  <thead>
                    <tr>
            		 <th width="5%" align="center">ID</th>
           			 <th width="10%" align="center">Invoice Date</th>
            		 <th width="15%" align="left">Patient's Name</th>
           		 	 <th width="10%" align="left">Phone</th>
            		 <th width="15%" align="left">Referred by</th>
            		 <th width="15%" align="center">Test</th>
                     <th width="10%" align="left">Specimen No.</th>
                     <th width="10%" align="left">Result</th>
            		 <th width="10%" align="center"></th>
                    </tr>
                  </thead>
                  <tbody>
                   <?php
                    if(isset($labtest_array[0]['diagitems_id'])&&$labtest_array[0]['diagitems_id']!='')
                    {
                    	for($v=0;$v<count($labtest_array);$v++)
						{
							if($v%2==0){$class = 'gradeX';}else{$class = 'gradeC';}
							
							
							$diagitems_id = $labtest_array[$v]['diagitems_id'];
							$diagitems_id_encoded = base64_encode($diagitems_id);
							
							$patient_id = $labtest_array[$v]['patient_id'];
							$patient_id_encoded = base64_encode($patient_id);
							
							$diagnosis_id = $labtest_array[$v]['diagnosis_id'];
							
							$group_id = $labtest_array[$v]['group_id'];
							
							if($patient_id!=0)
							{
								$patientOb = new classPatient;
								$patientOb->setPatientAutoID($patient_id);
								$patient_info = $patientOb->retrievePatientByPatientID();
								
								$patient_name = $patient_info[0]['patient_fname'].' '.$patient_info[0]['patient_lname'];
								$patient_phone = $patient_info[0]['phone'];
							}
							else
							{
								$patient_name = 'Outdoor';
								$patient_phone = '';
							}
							
							if($labtest_array[$v]['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 = $labtest_array[$v]['referred_by'];
							}
							
							
							$retreiveTestOb = new classDiagnostic;
							$retreiveTestOb->setLabTestID($diagnosis_id);
							$labtest_info = $retreiveTestOb->retrieveLabTestsByLabTestID();
							
							$getGroupNameOb = new classDiagnostic;
							$group_name = $getGroupNameOb->retrieveTestGroupNameByID($group_id);
							
							if($labtest_info[0]['labtest_name']=='Blood Cross Matching'||$labtest_info[0]['labtest_name']=='Blood Cross Matching Simple')
							{
								$retrieveBCMOb = new classDiagnostic;
								$retrieveBCMOb->setDiagItemID($diagitems_id);
								$bcm_detail = $retrieveBCMOb->retrieveBloodCrossMatchDetailByItemID();
							}
							
							?>
							<tr class="<?php echo $class;?>">
                                <td align="center"><?php echo $labtest_array[$v]['diaginvoice_id'];?></td>                                <td align="center"><?php echo date('d M Y',$labtest_array[$v]['diagitem_date']);?></td>
                                <td align="left"><?php echo $patient_name;?></td>
                                <td align="left"><?php echo $patient_phone;?></td>
                                <td align="left"><?php echo $referred_by;?></td>
                                <td align="left"><?php echo $labtest_info['0']['labtest_name'];?></td>
                                <td align="left"><?php echo $labtest_array[$v]['specimen'];?></td>
                                <td align="left"><?php if($labtest_array[$v]['diagnosis_result']!=''){echo $labtest_array[$v]['diagnosis_result'].' '.$labtest_info['0']['unit'];}?></td>
                                <td align="center">
                                <?php
								$liqOb = new classDiagnosticLiquids;
								if($liqOb->checkTestCanPerformWithLiquid($diagnosis_id,$_SESSION['security']['location_id']))
								{
									if($labtest_info[0]['labtest_name']=='Blood Cross Matching'||$labtest_info[0]['labtest_name']=='Blood Cross Matching Simple')
							{
										if(isset($bcm_detail[0]['id'])&&$bcm_detail[0]['id']!='')
										{
											$text = 'Edit';
											?>
											<a href="#bloodcrossmatch_result-box" class="bloodcrossmatch_result-window bloodcrossmatch_result" id="<?php echo $v;?>"> <span class="label label-success label-mini"><?php echo $text;?></span></a>
											<?php
										}
										else
										{
											$text = 'Enter Result';
											?>
											<a href="#bloodcrossmatch_result-box" class="bloodcrossmatch_result-window bloodcrossmatch_result" id="<?php echo $v;?>"> <span class="label label-danger label-mini"><?php echo $text;?></span></a>
											<?php
										}
									}
									else
									{
										
										if($labtest_array[$v]['diagnosis_result']!='')
										{
											$text = 'Edit';
											?>
											<a href="#labtest_result-box" class="labtest_result-window labtest_data" id="<?php echo $v;?>"> <span class="label label-success label-mini"><?php echo $text;?></span></a>
											<?php
										}
										else
										{
											$text = 'Enter Result';
											?>
											<a href="#labtest_result-box" class="labtest_result-window labtest_data" id="<?php echo $v;?>"> <span class="label label-danger label-mini"><?php echo $text;?></span></a>
											<?php
											
										}
									}
								}
								else
								{
										$text = 'No Liquid';
										?>
										<a href="#" onclick="alert('No enough liquid to perform this test!');" ><span class="label label-danger label-mini"><?php echo $text;?></span></a>
										<?php
									
								}
								?>
                                </td>
							</tr>
                            
                            <input type="hidden" name="diagitems_id" class="set_to_pop" id="diagitems_id_<?php echo $v;?>" value="<?php echo $diagitems_id;?>">
                            <input type="hidden" name="diaginvoice_id" class="set_to_pop" id="diaginvoice_id_<?php echo $v;?>" value="<?php echo $labtest_array[$v]['diaginvoice_id'];?>">
                            <input type="hidden" name="patient_name" class="set_to_pop" id="patient_name_<?php echo $v;?>" value="<?php echo $patient_name;?>">
                            <input type="hidden" name="test_name" class="set_to_pop" id="test_name_<?php echo $v;?>" value="<?php echo $labtest_info['0']['labtest_name'];?>">
                            <input type="hidden" name="test_value" class="set_to_pop" id="test_value_<?php echo $v;?>" value="<?php echo $labtest_info['0']['normal_value'];?>">
                            <input type="hidden" name="test_unit" class="set_to_pop" id="test_unit_<?php echo $v;?>" value="<?php echo $labtest_info['0']['unit'];?>">
                            <input type="hidden" name="test_result" class="set_to_pop" id="test_result_<?php echo $v;?>" value="<?php echo $labtest_array[$v]['diagnosis_result'];?>">
                            <input type="hidden" name="group_name" class="set_to_pop" id="group_name_<?php echo $v;?>" value="<?php echo $group_name;?>">
                            <?php
							if(isset($bcm_detail[0]['id'])&&$bcm_detail[0]['id']!='')
							{
								?>
                                <input type="hidden" name="donor_name" class="set_to_pop" id="donor_name_<?php echo $v;?>" value="<?php echo $bcm_detail[0]['donor_name'];?>">
                                <input type="hidden" name="blood_group" class="set_to_pop" id="blood_group_<?php echo $v;?>" value="<?php echo $bcm_detail[0]['blood_group'];?>">
                                <input type="hidden" name="hb_antigen" class="set_to_pop" id="hb_antigen_<?php echo $v;?>" value="<?php echo $bcm_detail[0]['hb_antigen'];?>">
                                <input type="hidden" name="hc_antigen" class="set_to_pop" id="hc_antigen_<?php echo $v;?>" value="<?php echo $bcm_detail[0]['hc_anitgen'];?>">
                                <input type="hidden" name="hiv" class="set_to_pop" id="hiv_<?php echo $v;?>" value="<?php echo $bcm_detail[0]['hiv'];?>">
                                <input type="hidden" name="mp" class="set_to_pop" id="mp_<?php echo $v;?>" value="<?php echo $bcm_detail[0]['mp'];?>">
                                <input type="hidden" name="vdrl" class="set_to_pop" id="vdrl_<?php echo $v;?>" value="<?php echo $bcm_detail[0]['vdrl'];?>">
                                <input type="hidden" name="receipient_name" class="set_to_pop" id="receipient_name_<?php echo $v;?>" value="<?php echo $bcm_detail[0]['receipient_name'];?>">
                                <input type="hidden" name="recipient_blood_group" class="set_to_pop" id="recipient_blood_group_<?php echo $v;?>" value="<?php echo $bcm_detail[0]['recipient_blood_group'];?>">
                                
                                <input type="hidden" name="bcm_id" class="set_to_pop" id="bcm_id_<?php echo $v;?>" value="<?php echo $bcm_detail[0]['id'];?>">
                                
                                 <input type="hidden" name="remarks" class="set_to_pop" id="remarks_<?php echo $v;?>" value="<?php echo $bcm_detail[0]['remarks'];?>">
                                <?php
							}
						}
                    }
					else
					{
						?>
							<tr>
								<table>
									<tr>
										<td>No entries found!</td>
									</tr>
								</table>
							</tr>
						<?php
					}
                    ?>
                  </tbody>
                  <tfoot>
                  </tfoot>
                </table>
                
                <table>
                    <tr>
                        <td align="right"><?php if(!($_POST)){include('pagination.php');}?></td>
                    </tr>  
                </table>
                
              </div>
            </div>
          </section>
        </div>
      </div>
      <!-- page end-->
    </section>
  </section>
  <!-- InstanceEndEditable --><!--main content end-->
<!--right sidebar start-->
 
<!--right sidebar end-->
</section>
<!-- Placed js at the end of the document so the pages load faster -->
<!--Core js-->
<!--<script src="../js/jquery-1.10.2.min.js"></script>-->
  
 
<script src="../assets/jquery-ui/jquery-ui-1.10.1.custom.min.js"></script>
<script src="../bs3/js/bootstrap.min.js"></script>



<script src="../js/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="../popUp/popUp.js"></script>
<script src="../js/ajax.js"></script>

<script src="../js/lib/jquery.js"></script>
<script src="../assets/fullcalendar/fullcalendar/fullcalendar.min.js"></script>
<script src="../js/calendar/external-dragging-calendar.js"></script>
<script src="../js/accordion-menu/jquery.dcjqaccordion.2.7.js"></script>
<script src="../js/scrollTo/jquery.scrollTo.min.js"></script>
<script src="../js/nicescroll/jquery.nicescroll.js" type="text/javascript"></script>
<!--[if lte IE 8]><script language="javascript" type="text/javascript" src="js/flot-chart/excanvas.min.js"></script><![endif]-->
<script src="../assets/jQuery-slimScroll-1.3.0/jquery.slimscroll.js"></script>
<script src="../assets/skycons/skycons.js"></script>
<script src="../assets/jquery.scrollTo/jquery.scrollTo.js"></script>
<script src="../js/jquery.easing.min.js"></script>
<script src="../assets/calendar/clndr.js"></script>
<script src="../js/underscore-min.js"></script>
<script src="../assets/calendar/moment-2.2.1.js"></script>
<script src="../js/calendar/evnt.calendar.init.js"></script>
<script src="../assets/jvector-map/jquery-jvectormap-1.2.2.min.js"></script>
<script src="../assets/jvector-map/jquery-jvectormap-us-lcc-en.js"></script>
<script src="../assets/gauge/gauge.js"></script>



<!--clock init-->
<script src="../assets/css3clock/js/script.js"></script>
<!--Easy Pie Chart-->
<script src="../assets/easypiechart/jquery.easypiechart.js"></script>
<!--Sparkline Chart-->
<!--Morris Chart-->
<script src="../assets/morris-chart/morris.js"></script>
<script src="../assets/morris-chart/raphael-min.js"></script>
<!--jQuery Flot Chart-->
<script src="../assets/flot-chart/jquery.flot.animator.min.js"></script>
<script src="../assets/flot-chart/jquery.flot.growraf.js"></script>
<script src="../js/dashboard.js"></script>
<script src="../js/custom-select/jquery.customSelect.min.js" ></script>
<!--common script init for all pages-->
<script src="../js/scripts.js"></script>
<!--dynamic table initialization -->
<script src="../js/dynamic_table/dynamic_table_init.js"></script>



<!--dynamic table initialization -->
<script src="../js/dynamic_table/dynamic_table_init.js"></script>
<!--<start===================>-->
<script src="../js/lib/jquery.js"></script>


<script src="../bs3/js/bootstrap.min.js"></script>



<script class="include" type="text/javascript" src="../js/accordion-menu/jquery.dcjqaccordion.2.7.js"></script>

<script src="../js/scrollTo/jquery.scrollTo.min.js"></script>
<script src="../js/nicescroll/jquery.nicescroll.js" type="text/javascript"></script>
<!--Easy Pie Chart-->
<script src="../assets/easypiechart/jquery.easypiechart.js"></script>
<!--Sparkline Chart-->
<script src="../assets/sparkline/jquery.sparkline.js"></script>
<!--jQuery Flot Chart-->
<script src="../assets/flot-chart/jquery.flot.js"></script>
<script src="../assets/flot-chart/jquery.flot.tooltip.min.js"></script>
<script src="../assets/flot-chart/jquery.flot.resize.js"></script>
<script src="../assets/flot-chart/jquery.flot.pie.resize.js"></script>
<script type="text/javascript" src="../assets/bootstrap-daterangepicker/daterangepicker.js"></script>
<script type="text/javascript" src="../assets/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>

<!--dynamic table-->
<!--common script init for all pages-->
<script src="../js/scripts.js"></script>

<!--dynamic table initialization -->
<script src="../js/dynamic_table/dynamic_table_init.js"></script>

<script type="text/javascript" src="../datepicker/jquery-1.9.1.js"></script>
<script type="text/javascript" src="../datepicker/jquery-ui.js"></script>

<!--<script type="text/javascript" src="../popUp/jquery-1.9.0.js"></script>-->
<script type="text/javascript">

 function Popup(apri) { 
	window.open(apri,"","top=10,left=200,width=800,height=700,status=no,menubar=no,toolbar=no,scrollbars=yes"); 
 }
</script> 

<div id="update_password-box" class="update_password-popup">
    
    <div class="pop_header">
        <span>Change Password</span>
        <a href="#" class="pop_close" style="float:right;">Close (X)</a>
    </div>
    
    <table width="100%" border="0" cellspacing="2" cellpadding="2" class="panel">
      <tr>
        <td>
          <div id="result_update_password_form"></div>
          
          <form action="" method="post" id="update_password_form" class="cmxform form-horizontal" onSubmit="return false;">
          	
            <br>
            
         	<div class="form-group">
            <label class="control-label col-lg-3" for="lastname">New Password:</label>
                <div class="col-lg-6">
                    <input type="password" name="password" class="form-control" value="" id="exampleInputPassword1">
                </div>
            </div>
           
            <p align="right">
            	<input type="hidden" name="user_id" value="<?php if(isset($user_id)&&$user_id!=''){echo $user_id;}else{ echo 
				$_SESSION['security']['user_id'];}?>">
                <input type="hidden" name="updateUserPwd" value="yes">
                <input name="ajax_submit" type="submit" class="ajax_submit btn btn-info" value="Update"/>
            </p>
            
          </form>
          </td>
          
      </tr>
    </table>
</div> 
 
</body>  
<!-- InstanceEnd --></html>

<div id="labtest_result-box" class="labtest_result-popup">
    
    <div class="pop_header">
        <span>Blood Test Result Entry</span>
        <a href="#" class="pop_close" style="float:right;">Close (X)</a>
    </div>
    
    <table width="100%" border="0" cellspacing="2" cellpadding="2" class="panel">
      <tr>
        <td>
          <div id="result_insert_labtestresult_form" style="margin:10px;"></div>
          
          <form action="" method="post" id="insert_labtestresult_form" class="cmxform form-horizontal" onSubmit="return false;">
          
           	<div class="form-group">
              <label class="control-label col-lg-3" for="firstname">Patient Name:</label>
              <div class="col-lg-6" id="patient_name"></div>
            </div>
           
            <div class="form-group" id="group_name_div">
              <label class="control-label col-lg-3" for="firstname">Group Name:</label>
              <div class= "col-lg-6" id="group_name_view"></div>
            </div>
             
            <div class="form-group">
              <label class="control-label col-lg-3" for="firstname">Test Name:</label>
              <div class= "col-lg-6" id="labtest_name_view"></div>
            </div>
            
            <div class="form-group">
              <label class="control-label col-lg-3" for="firstname">Normal Value:</label>
              <div class= "col-lg-6" id="normal_value_view"></div>
            </div>
            
            <div class="form-group">
              <label class="control-label col-lg-3" for="firstname">Test Result:</label>
              <div class= "col-lg-6">
              <input type="text" name="test_result" id="test_result_view" value="">
              <span id="test_unit_view" style="width:30%;"></span>
              
              </div>
              
            </div>
            
           
            
           	<p align="right">
              <input type="hidden" name="labtest_result" value="yes">
              <input type="hidden" name="redirect_url"  value="diaglabtests.php">
              <input type="hidden" name="diagitems_id" id="diagitems_id" value="">
              <input name="ajax_submit" type="submit" class="ajax_submit btn btn-info" value="Save" />
            </p>
            
          </form>
          </td>
          
      </tr>
    </table>
</div>

<div id="bloodcrossmatch_result-box" class="bloodcrossmatch_result-popup">
    
    <div class="pop_header">
        <span>Blood Cross Match Result Entry</span>
        <a href="#" class="pop_close" style="float:right;">Close (X)</a>
    </div>
    
    <table width="100%" border="0" cellspacing="2" cellpadding="2" class="panel">
      <tr>
        <td>
          <div id="result_bloodcrossmatch_result_form" style="margin:10px;"></div>
          
          <form action="" method="post" id="bloodcrossmatch_result_form" class="cmxform form-horizontal" onSubmit="return false;">
          
           	<div class="form-group">
              <label class="control-label col-lg-3" for="firstname">Patient Name:</label>
              <div class="col-lg-6" id="bcm_patient_name"></div>
            </div>
           
            <div class="form-group">
              <label class="control-label col-lg-3" for="firstname">Donor's Name:</label>
              <div class= "col-lg-6" style="width:25%;">
              <input type="text" name="donor_name" id="donor_name_value" value="">
              </div>
               <label class="control-label col-lg-3" for="firstname" style="width:15%;">Blood Group:</label>
              <div class= "col-lg-6" style="width:25%;">
              <input type="text" name="blood_group" id="blood_group_value" value="">
              </div>
            </div>
            
            <div class="form-group tests">
              <label class="control-label col-lg-3" for="firstname">Hepatitis-B Antigen:</label>
              <div class= "col-lg-6">
              <input type="text" name="hb_antigen" id="hb_antigen_value" value="">
              </div>
            </div>
            
            <div class="form-group tests">
              <label class="control-label col-lg-3" for="firstname">Hepatitis-C Antigen:</label>
              <div class= "col-lg-6">
              <input type="text" name="hc_antigen" id="hc_antigen_value" value="">
              </div>
            </div>
            
            <div class="form-group tests">
              <label class="control-label col-lg-3" for="firstname">H.I.V:</label>
              <div class= "col-lg-6">
              <input type="text" name="hiv" id="hiv_value" value="">
              </div>
            </div>
            
            <div class="form-group tests">
              <label class="control-label col-lg-3" for="firstname">MP:</label>
              <div class= "col-lg-6">
              <input type="text" name="mp" id="mp_value" value="">
              </div>
            </div>
            
            <div class="form-group tests">
              <label class="control-label col-lg-3" for="firstname">VDRL:</label>
              <div class= "col-lg-6">
              <input type="text" name="vdrl" id="vdrl_value" value="">
              </div>
            </div>
            
            <hr>
            
            <div class="form-group">
                <label class="control-label col-lg-3" for="firstname">Recipient's Name:</label>
                <div class= "col-lg-6">
                	<input type="text" name="recipient_name" id="recipient_name_value" value="">
                </div>
            </div>
            
            <div class="form-group">
                <label class="control-label col-lg-3" for="firstname">Recipient's Blood Group:</label>
                <div class= "col-lg-6">
                	<input type="text" name="recipient_bg" id="recipient_bg_value" value="">
                </div>
            </div>
            
            <hr>
            
            <div class="form-group">
                <label class="control-label col-lg-3" for="firstname">Remarks:</label>
                <div class= "col-lg-6">
                	<input type="text" name="remarks" id="remarks_value" value="">
                </div>
            </div>
             
           	<p align="right">
              <input type="hidden" name="blood_crossmatcth_report" id="blood_crossmatcth_report" value="yes">
              
              <input type="hidden" name="redirect_url"  value="diaglabtests.php">
              <input type="hidden" name="diagitems_id" id="bcm_diagitems_id" value="">
              <input type="hidden" name="diaginvoice_id" id="diaginvoice_id" value="">
              <input type="hidden" name="bcm_id" id="bcm_id" value="">
              <input name="ajax_submit" type="submit" class="ajax_submit btn btn-info" value="Save" />
            </p>
            
          </form>
          </td>
          
      </tr>
    </table>
</div>

<script>

$(".labtest_data").click(function() {
	
	var id = this.id;
	
	diagitems_id = $("#diagitems_id_"+id).val();
	test_name = $("#test_name_"+id).val();
	test_value = $("#test_value_"+id).val();
	test_unit = $("#test_unit_"+id).val();
	test_result = $("#test_result_"+id).val();
	patient_name = $("#patient_name_"+id).val();
	group_name = $("#group_name_"+id).val();
	
	
	$("#diagitems_id").val(diagitems_id);
	$("#labtest_name_view").html(test_name);
	$("#normal_value_view").html(test_value);
	$("#test_unit_view").html(test_unit);
	$("#test_result_view").val(test_result);
	$("#patient_name").html(patient_name);
	if(group_name!='')
	{
		$("#group_name_div").show();
		$("#group_name_view").html(group_name);
	}
	else
	{
		$("#group_name_div").hide();
	}
	
	
});
</script>

<script>

$(".bloodcrossmatch_result").click(function() {
	
	var id = this.id;
	
	test_name = $("#test_name_"+id).val();
	
	diaginvoice_id = $("#diaginvoice_id_"+id).val();
	diagitems_id = $("#diagitems_id_"+id).val();
	patient_name = $("#patient_name_"+id).val();
	bcm_id= $("#bcm_id_"+id).val();
	
	donor_name = $("#donor_name_"+id).val();
	blood_group = $("#blood_group_"+id).val();
	
	hb_antigen = $("#hb_antigen_"+id).val();
	hc_antigen = $("#hc_antigen_"+id).val();
	hiv = $("#hiv_"+id).val();
	mp = $("#mp_"+id).val();
	vdrl = $("#vdrl_"+id).val();
	
	recipient_name = $("#receipient_name_"+id).val();
	recipient_blood_group = $("#recipient_blood_group_"+id).val();
	
	remarks = $("#remarks_"+id).val();
	
	$("#diaginvoice_id").val(diaginvoice_id);
	$("#bcm_diagitems_id").val(diagitems_id);
	$("#bcm_patient_name").html(patient_name);
	$("#bcm_id").val(bcm_id);
	
	$("#donor_name_value").val(donor_name);
	$("#blood_group_value").val(blood_group);
	
	if(test_name=='Blood Cross Matching Simple')
	{
		$("#hb_antigen_value").val("0");
		$("#hc_antigen_value").val("0");
		$("#hiv_value").val("0");
		$("#mp_value").val("0");
		$("#vdrl_value").val("0");
		
		$(".tests").hide();
		
	}
	else
	{
		$("#hb_antigen_value").val(hb_antigen);
		$("#hc_antigen_value").val(hc_antigen);
		$("#hiv_value").val(hiv);
		$("#mp_value").val(mp);
		$("#vdrl_value").val(vdrl);
	}
	
	$("#recipient_name_value").val(recipient_name);
	$("#recipient_bg_value").val(recipient_blood_group);
	
	$("#remarks_value").val(remarks);
	
	
	
	
});
</script>