-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathsingle-patient.php
151 lines (148 loc) · 6.94 KB
/
single-patient.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<?php
session_start();
if (!isset($_SESSION['patientId'])) {
header("Location: dashboard.php");
}
error_reporting(0);
include('includes/dbconnection.php');
if (strlen($_SESSION['sessionid']==0)) {
header('location:logout.php');
} else
{
$patient_id = $_GET['patient_id'];
if ($_SESSION['patientId'] != $patient_id) {
header("Location: dashboard.php");
}
if(isset($_GET['patient_id']))
{
$query = "SELECT * FROM patients WHERE id ='$patient_id'";
$result = mysqli_query($con,$query);
}
else
{
header('location:manage-patients.php');
}
?>
<?php
while($row = mysqli_fetch_assoc($result)){
$patientName= $row['patient_name'];
$patientEmail = $row['email'];
$phoneNumber = $row['phone'];
$idNumber = $row['identification'];
$gender = $row['gender'];
$guardian = $row['guardian'];
$residence = $row['residence'];
if($row['status'] ==1){
$status = "Active";
}else{
$status = "Inactive";
}
$bloodgroup = $row['blood'];
$date = $row['dob'];
}
?>
<?php include 'includes/header.php';?>
<div class="main-content">
<div class="title">
Patient's Information
</div>
<div class="main">
<div class="profile">
<div class="patient-photo">
<div class="profile-image">
<img src="assets/images/big.jpg" alt="">
<p> Name: <?php echo $patientName; ?></p>
<p>Phone: <?php echo $phoneNumber; ?></p>
</div>
</div>
<div class="patient-info">
<div class="info-one">
<h4>Name: <p><?php echo $patientName;?></p></h4>
<h4>IDNumber: <p><?php echo $idNumber;?></p></h4>
<h4>Gender: <p ><?php echo $gender;?></p></h4>
<h4>Status:<p style="color: #3bac2c; id="status";> <?php echo $status;?></p></h4>
</div>
<div class="info-two">
<h4>Guardian: <p><?php echo $guardian;?></p></h4>
<h4>Residence:<p> <?php echo $residence?></p></h4>
<h4>DoB: <p><?php echo $date;?></p></h4>
<h4>Bloodgroup:<p><?php echo $bloodgroup;?></p></h4>
</div>
</div>
</div>
<div class="info-header">
<ul>
<li><p><?php echo $patientName?>'s Medical History</p></li>
<li ><a href="record-visit.php?patient_id=<?php echo $patient_id?>" class="right"> <button>Record</button> </a></li>
<li><button onclick="changeStatus()">Discharge</button> </a></li>
<script>
function changeStatus()
{
let xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function()
{
if(this.readyState ==4 && this.status ==200)
{
document.getElementById("status").innerText = 0;
}
};
xmlhttp.open("GET","change-status.php?patient_id=<?php echo $patient_id ?>", true);
xmlhttp.send();
let reload = window.location.reload();
}
</script>
</ul>
</div>
<table class="table">
<thead>
<th>#</th>
<th>Date Admited</th>
<th>Diagnosed With</th>
<th>Hospital Admitted</th>
<th>Medication</th>
<th>Date Discharged</th>
</thead>
<tbody>
<?php
if (isset($_GET['pageNo'])) {
$pageNo = $_GET['pageNo'];
} else {
$pageNo = 1;
}
$per_page = 10;
$offset = ($pageNo-1) * $per_page;
$query = "SELECT COUNT(*) FROM tblvisits WHERE patient_id = '$patient_id'";
$result = mysqli_query($con,$query);
$rows = mysqli_fetch_array($result)[0];
$total_pages = ceil($rows / $per_page);
$sql = "SELECT * FROM tblvisits WHERE patient_id = '$patient_id' ORDER BY visit_id DESC LIMIT $offset, $per_page";
$result = mysqli_query($con,$sql);
$count= 0;
while($row = mysqli_fetch_assoc($result)){
$date1 = $row['admision_date'];
$hospital = $row['hospital_id'];
$hssql = "SELECT * FROM hospitals WHERE id = '$hospital'";
$hsresult = mysqli_query($con,$hssql);
$hsRow = mysqli_fetch_assoc($hsresult);
$hsname = $hsRow['hospital_name'];
$medicine = $row['drugs'];
$disease = $row['diagnosed_with'];
$date2 = $row['date_discharged'];
$count+= 1;
?>
<tr>
<td data-label="Serial"><?php echo $count;?></td>
<td data-label="Date Admitted"><?php echo $date1; ?></td>
<td data-label="Disease"><?php echo $disease; ?></td>
<td data-label="Hospital"><?php echo $hsname; ?></td>
<td data-label="Medicine"><?php echo $medicine; ?></td>
<td data-label="Date Discharged"><?php echo $date2; ?></td>
</tr>
<?php }?>
</tbody>
</table>
</div>
</div>
<?php include_once('includes/footer.php');?>
<?php
}?>