forked from Anthonyk3801/Elderly-Care-Management-System
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpatientHome.php
More file actions
212 lines (186 loc) · 5.99 KB
/
patientHome.php
File metadata and controls
212 lines (186 loc) · 5.99 KB
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
<?php
session_start();
/*if(!isset($_SESSION['level'])) header('location:home.php');
if(isset($_SESSION['level'])){
if($_SESSION['level'] != 5) header('location:extras/transfer.php');
};
if($_GET['error'] == 2) echo "You are not authorized for that page";
*/
include 'db_connection.php';
?>
<?php //TEMPLATES
include 'templates/header.html';
switch($_SESSION['level']) {
case '1':
include 'templates/main-nav-bar.php';
include 'templates/main-grid-content-2columns.html';
include 'templates/admin-side-bar.html';
break;
case '2':
include 'templates/main-nav-bar.php';
include 'templates/main-grid-content-2columns.html';
include 'templates/supervisor-side-bar.html';
break;
case '3':
include 'templates/main-nav-bar.php';
include 'templates/main-grid-content-2columns.html';
include 'templates/doctor-side-bar.html';
break;
case '4':
include 'templates/main-nav-bar.php';
include 'templates/main-grid-content-2columns.html';
include 'templates/caregiver-side-bar.html';
break;
case '5':
include 'templates/main-nav-bar.php';
include 'templates/main-grid-content-2columns.html';
include 'templates/patient-side-bar.html';
break;
case '6':
include 'templates/main-nav-bar.php';
include 'templates/main-grid-content-2columns.html';
include 'templates/familyMember-side-bar.html';
break;
default:
include 'templates/alert-message-before-login.html';
include 'templates/home-nav-bar.html';
include 'templates/main-grid-content-1column.html';
}
include 'templates/main-content.html';
?>
<head>
<link rel="stylesheet" href="CSS/patientHomeStyle.css">
</head>
<h1 class="text-center">Patient's Home</h1>
<hr>
<?php
$sql = "SELECT patientID, fName, lName
FROM Patient";
$result = $conn->query($sql);
$patN = $result->fetch_assoc();
$patient = $patN['fName'] . " " . $patN['lName'];
$sql = "SELECT patientID, fName, lName
FROM Patient";
$result = $conn->query($sql);
$patID = $result->fetch_assoc();
$pat = $patID['patientID'];
?>
<div class="mt-5 mb-5">
<form action="patientHome.php" method="POST" id="patientForm">
<label for="patientID">Patient ID:</label>
<input readonly class="text-center" type="number" name="patientID" id="patientID" required value='<?php echo $_SESSION['id'];?>' min="1">
<br><br>
<label for="fName">Patient Name:</label>
<input readonly class="text-center" type="text" name="fName" id="fName" required value='<?php echo $_SESSION['fName']. " " . $_SESSION['lName'];?>'>
<br><br>
<label for="date">Date:</label>
<input class="text-end" type='date' name="date" id='date' value='<?php echo date('Y-m-d');?>'>
<br><br>
<button class="w-100 btn btn-sm btn-info text-light mt-3 mb-1" type="submit" value="search" name="search" id="search">Submit</button>
</form>
</div>
<?php
$caregiver = "";
$doctor = "";
if(isset($_POST['search'])){
$patient = $_SESSION['fName']. " " . $_SESSION['lName'];
$pat = $_SESSION['id'];
$sql = "SELECT *
FROM PatientChecklist
WHERE date = '$_POST[date]'";
$result = $conn->query($sql);
$res = $result->fetch_assoc();
$cnt = mysqli_num_rows($result);
if ( 0 === $cnt ) {
echo "<p style='color:red;'>Wrong PatientID or Patient Name</p>";
}else {
$sql = "SELECT *
FROM Patient
WHERE patientID = $_POST[patientID]";
$result = $conn->query($sql);
$patient = $result->fetch_assoc();
$group = $patient['groupID'];
$sql = "SELECT *
FROM Roster
WHERE date = '$_POST[date]'";
$result = $conn->query($sql);
$roster = $result->fetch_assoc();
if($group == 1) $careID = $roster['careGiver1'];
if($group == 2) $careID = $roster['careGiver2'];
if($group == 3) $careID = $roster['careGiver3'];
if($group == 4) $careID = $roster['careGiver4'];
$doctorID = $roster['doctorID'];
$sql = "SELECT *
FROM Employee
WHERE employeeID = $doctorID";
$result = $conn->query($sql);
$employee = $result->fetch_assoc();
$doctor = $employee['fName'] . " " . $employee['lName'];
$sql = "SELECT *
FROM Employee
WHERE employeeID = $careID";
$result = $conn->query($sql);
$emp = $result->fetch_assoc();
$caregive = $emp['fName'] . " " . $emp['lName'];
$sql = "SELECT *
FROM DoctorAppointments
WHERE patientID = $_POST[patientID] AND date = '$_POST[date]'";
$result = $conn->query($sql);
$appoint = $result->fetch_assoc();
echo "<table width='30%' border=0>";
echo "<th>Doctor's Name</th>";
echo "<th>Doctor's Appointment </th>";
echo "<th>Caregiver's Name</th>";
echo "<th>Morning Medicine</th>";
echo "<th>Afternoon Medicine</th>";
echo "<th>Night Medicine</th>";
echo "<th>Breakfast</th>";
echo "<th>Lunch</th>";
echo "<th>Dinner</th>";
echo "</tr>";
echo "<tr>";
echo "<td>".$doctor."</td>";
if(isset($appoint['time'])){
echo "<td> Appointment Time: " . $appoint['time'] . " </td>";
}else{
echo "<td> No Appointment </td>";
}
echo "<td>".$caregive."</td>";
if($res['morningMedCheck'] == 0) {
echo "<td> X </td>";
}elseif($res['morningMedCheck'] == 1){
echo "<td> ✔ </td>";
}
if($res['lunchMedCheck'] == 0) {
echo "<td> X </td>";
}elseif($res['lunchMedCheck'] == 1){
echo "<td> ✔ </td>";
}
if($res['nightMedCheck'] == 0) {
echo "<td> X </td>";
}elseif($res['nightMedCheck'] == 1){
echo "<td> ✔ </td>";
}
if($res['breakfast'] == 0) {
echo "<td> X </td>";
}elseif($res['breakfast'] == 1){
echo "<td> ✔ </td>";
}
if($res['lunch'] == 0) {
echo "<td> X </td>";
}elseif($res['lunch'] == 1){
echo "<td> ✔ </td>";
}
if($res['dinner'] == 0) {
echo "<td> X </td>";
}elseif($res['dinner'] == 1){
echo "<td> ✔ </td>";
}
}
}
echo "</table>";
?>
<?php // TEMPLATES
include 'templates/end-main-content.html';
include 'templates/footer.html';
?>