<?php
session_start();
error_reporting(0);
include('include/config.php');
include('include/checklogin.php');
check_login();
if(isset($_POST['submit']))
{    
  $vid=$_GET['viewid'];
  $bp=$_POST['bp'];
  $bs=$_POST['bs'];
  $weight=$_POST['weight'];
  $temp=$_POST['temp'];
  $hiv=$_POST['hiv'];
  $hcv=$_POST['hcv'];
  $hbsag=$_POST['hbsag'];
  $vdrl=$_POST['vdrl'];
  $tpha=$_POST['tpha'];
  $hb=$_POST['hb'];
  $eye=$_POST['eye'];
  $height=$_POST['height'];
  $bg=$_POST['bg'];
  $pg=$_POST['pg'];
  $urine=$_POST['urine'];
  $xray=$_POST['xray'];
  $general=$_POST['general'];
  $other=$_POST['other'];
 $pres=$_POST['pres'];
 

    $query.=mysqli_query($con, "insert   tblmedicalhistory(PatientID,BloodPressure,BloodSugar,Weight,Temperature,Hiv,Hcv,Hbsag,Vdrl,Tpha,Hb,Eye,Height,Bgroup,Pgtest,Urinalysis,Xray,Other,General,MedicalPres)
    value('$vid','$bp','$bs','$weight','$temp','$hiv','$hcv','$hbsag','$vdrl','$tpha','$hb','$eye','$height','$bg','$pg','$urine','$xray','$general','$other','$pres')");    
    if ($query) {
  echo '<script>alert("Medicle history has been added.")</script>';
  echo "<script>window.location.href ='manage-patient.php'</script>";
}
else
  {
    echo '<script>alert("Something Went Wrong. Please try again")</script>';
  }


}

?>
<!DOCTYPE html>
<html lang="en">
	<head>
  <link rel="icon" href="logo.png">
		<title>Doctor | Manage Patients</title>
		
		<link href="http://fonts.googleapis.com/css?family=Lato:300,400,400italic,600,700|Raleway:300,400,500,600,700|Crete+Round:400italic" rel="stylesheet" type="text/css" />
		<link rel="stylesheet" href="vendor/bootstrap/css/bootstrap.min.css">
		<link rel="stylesheet" href="vendor/fontawesome/css/font-awesome.min.css">
		<link rel="stylesheet" href="vendor/themify-icons/themify-icons.min.css">
		<link href="vendor/animate.css/animate.min.css" rel="stylesheet" media="screen">
		<link href="vendor/perfect-scrollbar/perfect-scrollbar.min.css" rel="stylesheet" media="screen">
		<link href="vendor/switchery/switchery.min.css" rel="stylesheet" media="screen">
		<link href="vendor/bootstrap-touchspin/jquery.bootstrap-touchspin.min.css" rel="stylesheet" media="screen">
		<link href="vendor/select2/select2.min.css" rel="stylesheet" media="screen">
		<link href="vendor/bootstrap-datepicker/bootstrap-datepicker3.standalone.min.css" rel="stylesheet" media="screen">
		<link href="vendor/bootstrap-timepicker/bootstrap-timepicker.min.css" rel="stylesheet" media="screen">
		<link rel="stylesheet" href="assets/css/styles.css">
		<link rel="stylesheet" href="assets/css/plugins.css">
    <link rel="stylesheet" href="print.css" media="print">
		<link rel="stylesheet" href="assets/css/themes/theme-1.css" id="skin_color" />
	</head>
	<body>
		<div id="app">		
<?php include('include/sidebar.php');?>
<div class="app-content">
<?php include('include/header.php');?>
<div class="main-content" >
<div class="wrap-content container" id="container">
						<!-- start: PAGE TITLE -->
<div class="container-fluid container-fullw bg-white">
<div class="row">
<div class="col-md-12">
<?php
                               $vid=$_GET['viewid'];
                               $ret=mysqli_query($con,"select * from tblpatient where ID='$vid'");
$cnt=1;
while ($row=mysqli_fetch_array($ret)) {
                               ?>
<table border="1" class="table table-bordered">
<tr align="center">
 <th colspan="8" >
  <h1 align="Center"><img src="logo.png" align="Left" style="height: 100px; width: 100px;">ADIMEC MEDICAL REPORT
  <?php echo '<img src="../upload/'.$row['Img'].'" align="Right" style="height: 100px; width: 100px;">' ?></h1>
  </th>
</tr>
<tr align="center">
<td colspan="4" style="font-size:20px;color:blue">
Patient Details</td></tr>

<tr>
    <th scope>Patient Name</th>
    <td><?php  echo $row['PatientName'];?></td>
    <th scope>Patient Email</th>
    <td><?php  echo $row['PatientEmail'];?></td>
  </tr>
  <tr>
    <th scope>Patient Mobile Number</th>
    <td><?php  echo $row['PatientContno'];?></td>
    <th>Patient Address</th>
    <td><?php  echo $row['PatientAdd'];?></td>
  </tr>
  <tr>
    <th scope>Patient Passport/ ID</th>
    <td><?php  echo $row['Patientpass'];?></td>
    <th>Patient Next of Kin</th>
    <td><?php  echo $row['Patientkin'];?></td>
  </tr>
  <tr>
    <th scope>Patient Kin Relation</th>
    <td><?php  echo $row['Patientkinr'];?></td>
    <th>Patient Kin Number</th>
    <td><?php  echo $row['Patientkinum'];?></td>
  </tr>
    <tr>
    <th>Patient Gender</th>
    <td><?php  echo $row['PatientGender'];?></td>
    <th>Patient Age</th>
    <td><?php  echo $row['PatientAge'];?></td>
  </tr>
  </tr>
    <tr>
    <th>Agent Details</th>
    <td><?php  echo $row['Agent'];?></td>
    <th>Agent Number</th>
    <td><?php  echo $row['Agentnum'];?></td>
  </tr>
  <tr>
    <th>Allergies (if any)</th>
    <td><?php  echo $row['PatientMedhis'];?></td>
     <th>Patient Reg Date</th>
    <td><?php  echo $row['CreationDate'];?></td>
  </tr>
 
<?php }?>
</table>
<?php  

$ret=mysqli_query($con,"select * from tblmedicalhistory  where PatientID='$vid'");



 ?>
<table id="datatable" class="table table-bordered dt-responsive nowrap" style="border-collapse: collapse; border-spacing: 0; width: 100%;">
  <tr align="center">
   <th colspan="8" >Medical History</th> 
  </tr>
  <tr align="center">
  <th colspan="8" align="center">GENERAL EXAMINATION</th> 
</tr>
<?php  
while ($row=mysqli_fetch_array($ret)) { 
  ?>
<tr>
  <td>Blood Pressure</td>
  <td><?php  echo $row['BloodPressure'];?></td>
  <td>Blood Group</td>
  <td><?php  echo $row['Bgroup'];?></td>
</tr>
<tr>
  <td>Body Temperature</td>
  <td><?php  echo $row['Temperature'];?></td>
  <td>BloodSugar</td>
  <td><?php  echo $row['BloodSugar'];?></td>
</tr>
<tr>
  <td>Eye/ Ear Exam</td>
  <td><?php  echo $row['Eye'];?></td>
  <td>HB</td>
  <td><?php  echo $row['Hb'];?></td> 
</tr>
<tr>
  <td>Height</td>
  <td><?php  echo $row['Height'];?></td>
  <td>General Body</td>
  <td><?php  echo $row['General'];?></td> 
</tr>
<tr>
  <td>Weight</td>
  <td><?php  echo $row['Weight'];?></td>
  <td></td>
  <td></td>
</tr>
<tr align="center">
  <th colspan="8" align="center">PATHOLOGY</th> 
</tr>
<tr>
  <td>HIV</td>
  <td><?php  echo $row['Hiv'];?></td>
  <td>TPHA</td>
  <td><?php  echo $row['Tpha'];?></td>
</tr>
<tr>
  <td>HCV</td>
  <td><?php  echo $row['Hcv'];?></td>
  <td>Pregnancy</td>
  <td><?php  echo $row['Pgtest'];?></td>
</tr>
<tr>
  <td>HBsAg</td>
  <td><?php  echo $row['Hbsag'];?></td>
  <td>Urinalisys</td>
  <td><?php  echo $row['Urinalysis'];?></td> 
</tr>
<tr>
  <td>VDRL</td>
  <td><?php  echo $row['Vdrl'];?></td>
  <td>Others</td>
  <td><?php  echo $row['Other'];?></td> 
</tr>
<tr align="center">
  <th colspan="8" align="center">X-Ray Report</th> 
</tr>
<tr align="center">
  <th colspan="8" align="center"><?php  echo $row['Xray'];?></th>
</tr>
<tr align="center">
  <th colspan="8" align="center">Doctor's Remarks</th> 
</tr>
<tr align="center">
  <th colspan="8" align="center"><?php  echo $row['MedicalPres'];?></th>
</tr>
<?php $cnt=$cnt+1;}?>
</table>
</table>

<div class="print">
<p align="center"> 
<button class="btn btn-primary waves-effect waves-light w-lg" onclick="window.print();" id="print">Print</button>                           
<button class="btn btn-primary waves-effect waves-light w-lg" data-toggle="modal" data-target="#myModal">Add Medical History</button>
<button class="btn btn-primary waves-effect waves-light w-lg" data-toggle="modal" data-target="#myModal2">Update Medical History</button>
</p>
</div>
<?php  ?>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog" role="document">
     <div class="modal-content">
      <div class="modal-header">
                                                    <h5 class="modal-title" id="exampleModalLabel">Add Medical History</h5>
                                                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                                        <span aria-hidden="true">&times;</span>
                                                    </button>
                                                </div>
                                                <div class="modal-body">
                                                <table class="table table-bordered table-hover data-tables">

                                 <form method="post" name="submit">

                                 <tr>
    <th>Blood Pressure :</th>
    <td>
    <input name="bp" placeholder="Blood Pressure" class="form-control wd-450" required="true"></td>
  </tr>                          
  <tr>
    <th>Blood Sugar :</th>
    <td>
    <input name="bs" placeholder="Blood Sugar" class="form-control wd-450" required="true"></td>
  </tr> 
  <tr>
    <th>Weight :</th>
    <td>
    <input name="weight" placeholder="Weight" class="form-control wd-450" required="true"></td>
  </tr>
  <tr>
    <th>Body Temprature :</th>
    <td>
    <input name="temp" placeholder="Body Temperature" class="form-control wd-450" required="true"></td>
  </tr>                  
  <tr>
    <th>HIV :</th>
    <td>
    <input name="hiv" placeholder="HIV" class="form-control wd-450" required="true"></td>
  </tr>                          
     <tr>
    <th>HCV :</th>
    <td>
    <input name="hcv" placeholder="HCV" class="form-control wd-450" required="true"></td>
  </tr> 
  <tr>
    <th>HBsAg :</th>
    <td>
    <input name="hbsag" placeholder="HBsAg" class="form-control wd-450" required="true"></td>
  </tr>
  <tr>
    <th>VDRL :</th>
    <td>
    <input name="vdrl" placeholder="VDRL" class="form-control wd-450" required="true"></td>
  </tr>  
  <tr>
    <th>TPHA :</th>
    <td>
    <input name="tpha" placeholder="TPHA" class="form-control wd-450" required="true"></td>
  </tr>                          
     <tr>
    <th>HB :</th>
    <td>
    <input name="hb" placeholder="HB" class="form-control wd-450" required="true"></td>
  </tr> 
  <tr>
    <th>Eye & Ear :</th>
    <td>
    <input name="eye" placeholder="Eye & Ear" class="form-control wd-450" required="true"></td>
  </tr>
  <tr>
    <th>Height :</th>
    <td>
    <input name="height" placeholder="Height" class="form-control wd-450" required="true"></td>
  </tr>
  <tr>
    <th>Blood Group :</th>
    <td>
    <input name="bg" placeholder="Blood Group" class="form-control wd-450" required="true"></td>
  </tr>
  <tr>
    <th>Pregnancy Test :</th>
    <td>
    <input name="pg" placeholder="Pregnancy Test" class="form-control wd-450" required="true"></td>
  </tr>
  <tr>
    <th>Urinalysis :</th>
    <td>
    <input name="urine" placeholder="Urinalysis" class="form-control wd-450" required="true"></td>
  </tr>
  <tr>
    <th>X-Ray Report :</th>
    <td>
    <textarea name="xray" placeholder="X-Ray Report" rows="12" cols="14" class="form-control wd-450" required="true"></textarea></td>
  </tr>
  <tr>
    <th>Other Remarks :</th>
    <td>
    <textarea name="other" placeholder="Other Remarks" rows="12" cols="14" class="form-control wd-450" required="true"></textarea></td>
  </tr>
  <tr>
    <th>General Body Report :</th>
    <td>
    <textarea name="general" placeholder="General Body Report" rows="12" cols="14" class="form-control wd-450" required="true"></textarea></td>
  </tr>               
  <tr>
    <th>Medical Report :</th>
    <td>
    <textarea name="pres" placeholder="Medical Report" rows="12" cols="14" class="form-control wd-450" required="true"></textarea></td>
  </tr>  
   
</table>
</div>
<div class="modal-footer">
 <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
 <button type="submit" name="submit" class="btn btn-primary">Submit</button>
  
  </form>
</div>
</div>
</div>
</div>
<?php
if(isset($_POST['update']))
{    
  $vid=$_GET['viewid'];
  $bp=$_POST['bp'];
  $bs=$_POST['bs'];
  $weight=$_POST['weight'];
  $temp=$_POST['temp'];
  $hiv=$_POST['hiv'];
  $hcv=$_POST['hcv'];
  $hbsag=$_POST['hbsag'];
  $vdrl=$_POST['vdrl'];
  $tpha=$_POST['tpha'];
  $hb=$_POST['hb'];
  $eye=$_POST['eye'];
  $height=$_POST['height'];
  $bg=$_POST['bg'];
  $pg=$_POST['pg'];
  $urine=$_POST['urine'];
  $xray=$_POST['xray'];
  $general=$_POST['general'];
  $other=$_POST['other'];
 $pres=$_POST['pres'];
 

    $sql.=mysqli_query($con, "update tblmedicalhistory set BloodPressure= '$bp', BloodSugar= '$bs', Weight= '$weight',Temperature= '$temp',Hiv= '$hiv',Hcv= '$hcv',
    Hbsag= '$hbsag',Vdrl= '$vdrl',Tpha= '$tpha',Hb= '$hb',Eye= '$eye',Height= '$height',Bgroup= '$bg',Pgtest= '$pg',Urinalysis= '$urine',Xray= '$xray',
    Other= '$other',General= '$general',MedicalPres= '$pres' where PatientID='$vid'");    
    if ($sql) {
  echo '<script>alert("Medical history has been Updated.")</script>';
  echo "<script>window.location.href ='manage-patient.php'</script>";
}
else
  {
    echo '<script>alert("Something Went Wrong. Please try again")</script>';
  }

}
$vid=$_GET['viewid'];
$ret=mysqli_query($con,"select * from tblmedicalhistory  where PatientID='$vid'"); 
$cnt=1;
while ($row=mysqli_fetch_array($ret)) {
?>
<div class="modal fade" id="myModal2" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog" role="document">
     <div class="modal-content">
      <div class="modal-header">
                                                    <h5 class="modal-title" id="exampleModalLabel">Update Medical History</h5>
                                                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                                        <span aria-hidden="true">&times;</span>
                                                    </button>
                                                </div>
<div class="modal-body">
<table class="table table-bordered table-hover data-tables">
  <form method="post" name="submit">
  <tr>
    <th>Blood Pressure :</th>
    <td>
    <input name="bp" placeholder="Blood Pressure" class="form-control wd-450" value="<?php  echo $row['BloodPressure'];?>" required="true"></td>
  </tr>                          
  <tr>
    <th>Blood Sugar :</th>
    <td>
    <input name="bs" placeholder="Blood Sugar" class="form-control wd-450" value="<?php  echo $row['BloodSugar'];?>" required="true"></td>
  </tr> 
  <tr>
    <th>Weight :</th>
    <td>
    <input name="weight" placeholder="Weight" class="form-control wd-450" value="<?php  echo $row['Weight'];?>" required="true"></td>
  </tr>
  <tr>
    <th>Body Temprature :</th>
    <td>
    <input name="temp" placeholder="Body Temperature" class="form-control wd-450" value="<?php  echo $row['Temperature'];?>" required="true"></td>
  </tr>                  
  <tr>
    <th>HIV :</th>
    <td>
    <input name="hiv" placeholder="HIV" class="form-control wd-450" required="true" value="<?php  echo $row['Hiv'];?>"></td>
  </tr>                          
     <tr>
    <th>HCV :</th>
    <td>
    <input name="hcv" placeholder="HCV" class="form-control wd-450" required="true" value="<?php  echo $row['Hcv'];?>"></td>
  </tr> 
  <tr>
    <th>HBsAg :</th>
    <td>
    <input name="hbsag" placeholder="HBsAg" class="form-control wd-450" required="true" value="<?php  echo $row['Hbsag'];?>"></td>
  </tr>
  <tr>
    <th>VDRL :</th>
    <td>
    <input name="vdrl" placeholder="VDRL" class="form-control wd-450" required="true" value="<?php  echo $row['Vdrl'];?>"></td>
  </tr>  
  <tr>
    <th>TPHA :</th>
    <td>
    <input name="tpha" placeholder="TPHA" class="form-control wd-450" required="true" value="<?php  echo $row['Tpha'];?>"></td>
  </tr>                          
     <tr>
    <th>HB :</th>
    <td>
    <input name="hb" placeholder="HB" class="form-control wd-450" required="true" value="<?php  echo $row['Hb'];?>"></td>
  </tr> 
  <tr>
    <th>Eye & Ear :</th>
    <td>
    <input name="eye" placeholder="Eye & Ear" class="form-control wd-450" required="true" value="<?php  echo $row['Eye'];?>"></td>
  </tr>
  <tr>
    <th>Height :</th>
    <td>
    <input name="height" placeholder="Height" class="form-control wd-450" required="true" value="<?php  echo $row['Height'];?>"></td>
  </tr>
  <tr>
    <th>Blood Group :</th>
    <td>
    <input name="bg" placeholder="Blood Group" class="form-control wd-450" required="true" value="<?php  echo $row['Bgroup'];?>"></td>
  </tr>
  <tr>
    <th>Pregnancy Test :</th>
    <td>
    <input name="pg" placeholder="Pregnancy Test" class="form-control wd-450" required="true" value="<?php  echo $row['Pgtest'];?>"></td>
  </tr>
  <tr>
    <th>Urinalysis :</th>
    <td>
    <input name="urine" placeholder="Urinalysis" class="form-control wd-450" required="true" value="<?php  echo $row['Urinalysis'];?>"></td>
  </tr>
  <tr>
    <th>X-Ray Report :</th>
    <td>
    <textarea name="xray" placeholder="X-Ray Report" rows="12" cols="14" class="form-control wd-450" required="true"><?php  echo $row['Xray'];?></textarea></td>
  </tr>
  <tr>
    <th>Other Remarks :</th>
    <td>
    <textarea name="other" placeholder="Other Remarks" rows="12" cols="14" class="form-control wd-450" required="true"><?php  echo $row['Other'];?></textarea></td>
  </tr>
  <tr>
    <th>General Body Report :</th>
    <td>
    <textarea name="general" placeholder="General Body Report" rows="12" cols="14" class="form-control wd-450" required="true"><?php  echo $row['General'];?></textarea></td>
  </tr>               
  <tr>
    <th>Medical Report :</th>
    <td>
    <textarea name="pres" placeholder="Medical Report" rows="12" cols="14" class="form-control wd-450" required="true"><?php  echo $row['MedicalPres'];?></textarea></td>
  </tr>  
   
</table>
</div>
<div class="modal-footer">
  <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
 <button type="submit" name="update" class="btn btn-primary">Update</button>
  
  </form>
</div>
</div>
</div>
</div>
<?php
  $cnt=$cnt+1; 
  }
  ?>
</div>
</div>
</div>
</div>
<div class="print">
			<!-- start: FOOTER -->
	<?php include('include/footer.php');?>
			<!-- end: FOOTER -->
		
			<!-- start: SETTINGS -->
	<?php include('include/setting.php');?>
			
			<!-- end: SETTINGS -->
      </div>
		</div>
		<!-- start: MAIN JAVASCRIPTS -->
		<script src="vendor/jquery/jquery.min.js"></script>
		<script src="vendor/bootstrap/js/bootstrap.min.js"></script>
		<script src="vendor/modernizr/modernizr.js"></script>
		<script src="vendor/jquery-cookie/jquery.cookie.js"></script>
		<script src="vendor/perfect-scrollbar/perfect-scrollbar.min.js"></script>
		<script src="vendor/switchery/switchery.min.js"></script>
		<!-- end: MAIN JAVASCRIPTS -->
		<!-- start: JAVASCRIPTS REQUIRED FOR THIS PAGE ONLY -->
		<script src="vendor/maskedinput/jquery.maskedinput.min.js"></script>
		<script src="vendor/bootstrap-touchspin/jquery.bootstrap-touchspin.min.js"></script>
		<script src="vendor/autosize/autosize.min.js"></script>
		<script src="vendor/selectFx/classie.js"></script>
		<script src="vendor/selectFx/selectFx.js"></script>
		<script src="vendor/select2/select2.min.js"></script>
		<script src="vendor/bootstrap-datepicker/bootstrap-datepicker.min.js"></script>
		<script src="vendor/bootstrap-timepicker/bootstrap-timepicker.min.js"></script>
		<!-- end: JAVASCRIPTS REQUIRED FOR THIS PAGE ONLY -->
		<!-- start: CLIP-TWO JAVASCRIPTS -->
		<script src="assets/js/main.js"></script>
		<!-- start: JavaScript Event Handlers for this page -->
		<script src="assets/js/form-elements.js"></script>
		<script>
			jQuery(document).ready(function() {
				Main.init();
				FormElements.init();
			});
		</script>
		<!-- end: JavaScript Event Handlers for this page -->
		<!-- end: CLIP-TWO JAVASCRIPTS -->
	</body>
</html>
