-
Notifications
You must be signed in to change notification settings - Fork 0
/
patientappointment.php
396 lines (357 loc) · 18.6 KB
/
patientappointment.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
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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
<?php
include("header.php");
include("dbconnection.php");
session_start();
if(isset($_POST['submit']))
{
if(isset($_SESSION['patientid']))
{
$lastinsid =$_SESSION['patientid'];
}
else
{
$dt = date("Y-m-d");
$tim = date("H:i:s");
$sql ="INSERT INTO patient(patientname,admissiondate,admissiontime,address,city,mobileno,loginid,password,gender,dob,status) values('$_POST[patiente]','$dt','$tim','$_POST[textarea]','$_POST[city]','$_POST[mobileno]','$_POST[loginid]','$_POST[password]','$_POST[select6]','$_POST[dob]','Active')";
if($qsql = mysqli_query($con,$sql))
{
echo "<script>alert('patient record inserted successfully...');</script>";
}
else
{
echo mysqli_error($con);
}
$lastinsid = mysqli_insert_id($con);
}
$sqlappointment="SELECT * FROM appointment WHERE appointmentdate='$_POST[appointmentdate]' AND appointmenttime='$_POST[appointmenttime]' AND doctorid='$_POST[doct]' AND status='Approved'";
$qsqlappointment = mysqli_query($con,$sqlappointment);
if(mysqli_num_rows($qsqlappointment) >= 1)
{
echo "<script>alert('Appointment already scheduled for this time..');</script>";
}
else
{
$sql ="INSERT INTO appointment(appointmenttype,patientid,appointmentdate,appointmenttime,app_reason,status,departmentid,doctorid) values('ONLINE','$lastinsid','$_POST[appointmentdate]','$_POST[appointmenttime]','$_POST[app_reason]','Pending','$_POST[department]','$_POST[doct]')";
if($qsql = mysqli_query($con,$sql))
{
echo "<script>alert('Appointment record inserted successfully...');</script>";
}
else
{
echo mysqli_error($con);
}
}
}
if(isset($_GET['editid']))
{
$sql="SELECT * FROM appointment WHERE appointmentid='$_GET[editid]' ";
$qsql = mysqli_query($con,$sql);
$rsedit = mysqli_fetch_array($qsql);
}
if(isset($_SESSION['patientid']))
{
$sqlpatient = "SELECT * FROM patient WHERE patientid=18 ";
$qsqlpatient = mysqli_query($con,$sqlpatient);
$rspatient = mysqli_fetch_array($qsqlpatient);
$readonly = " readonly";
}
?>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="wrapper col4">
<div id="container">
<?php
if(isset($_POST['submit']))
{
if(mysqli_num_rows($qsqlappointment) >= 1)
{
echo "<h2>Appointment already scheduled for ". date("d-M-Y", strtotime($_POST['appointmentdate'])) . " " . date("H:i A", strtotime($_POST['appointmenttime'])) . " .. </h2>";
}
else
{
if(isset($_SESSION['patientid']))
{
echo "<h2 class='text-center'>Appointment taken successfully.. </h2>";
echo "<p class='text-center'>Appointment record is in pending process. Kindly check the appointment status. </p>";
echo "<p class='text-center'> <a href='viewappointment.php'>View Appointment record</a>. </p>";
}
else
{
echo "<h2 class='text-center'>Appointment taken successfully.. </h2>";
echo "<p class='text-center'>Appointment record is in pending process. Please wait for confirmation message.. </p>";
echo "<p class='text-center'> <a href='patientlogin.php'>Click here to Login</a>. </p>";
}
}
}
else
{
?>
<!-- Content -->
<div id="content">
<!-- Make an Appointment -->
<section class="main-oppoiment " style="background-image:url('images/appointment.jpg');background-repeat: no-repeat;background-size: 75%;" >
<div class="container">
<div class="row">
<!-- Make an Appointment -->
<div class="col-lg-7">
<div class="appointment">
<!-- Heading -->
<div class="heading-block head-left margin-bottom-50">
<h4 style="color:black;font-weight:500;">Make an Appointment</h4>
</div>
<form method="post" action="" name="frmpatapp" onSubmit="return validateform()"
class="appointment-form">
<ul class="row">
<li class="col-sm-6">
<label>
<input placeholder="Patient's Name" type="text" class="form-control"
name="patiente" id="patiente"
value="<?php echo $rspatient['patientname']; ?>"
<?php echo $readonly; ?>>
<i class="icon-user"></i>
</label>
</li>
<li class="col-sm-6">
<label><input placeholder="Address" type="text" class="form-control"
name="textarea" id="textarea"
value="<?php echo $rspatient['address']; ?>"
<?php echo $readonly; ?>><i class="icon-compass"></i>
</label>
</li>
<li class="col-sm-6">
<label><input placeholder="City" type="text" class="form-control"
name="city" id="city" value="<?php echo $rspatient['city']; ?>"
<?php echo $readonly; ?>><i class="icon-pin"></i>
</label>
</li>
<li class="col-sm-6">
<label>
<input placeholder="Contact Number" type="text" class="form-control"
name="mobileno" id="mobileno"
value="<?php echo $rspatient['mobileno']; ?>"
<?php echo $readonly; ?>><i class="icon-phone"></i>
</label>
</li>
<?php
if(!isset($_SESSION['patientid']))
{
?>
<li class="col-sm-6">
<label>
<input placeholder="Login ID" type="email" class="form-control"
name="loginid" id="loginid"
value="<?php echo $rspatient['loginid']; ?>"
<?php echo $readonly; ?>><i class="icon-login"></i>
</label>
</li>
<li class="col-sm-6">
<label>
<input placeholder="Password" type="password" class="form-control"
name="password" id="password"
value="<?php echo $rspatient['password']; ?>"
<?php echo $readonly; ?>><i class="icon-lock"></i>
</label>
</li>
<?php
}
?>
<li class="col-sm-6">
<label>
<?php
if(isset($_SESSION['patientid']))
{
echo $rspatient['gender'];
}
else
{
?>
<select name="select6" id="select6" class="selectpicker">
<option value="" selected="" hidden="" value="<?php echo $rspatient['gender']?>">Select Gender</option>
<?php
$arr = array("Male","Female");
foreach($arr as $val)
{
echo "<option value='$val'>$val</option>";
}
?>
</select>
<?php
}
?>
</li>
<li class="col-sm-6">
<label>
<input placeholder="Date of birth" type="text" class="form-control"
name="dob" id="dob" onfocus="(this.type='date')"
value="<?php echo $rspatient['dob']; ?>" <?php echo $readonly; ?> max="<?php echo date("Y-m-d"); ?>"><i
class="ion-calendar"></i>
</label>
</li>
<li class="col-sm-6">
<label>
<input placeholder="Appointment Date" type="text" class="form-control"
min="<?php echo date("Y-m-d"); ?>" name="appointmentdate"
onfocus="(this.type='date')" id="appointmentdate"><i
class="ion-calendar"></i>
</label>
</li>
<li class="col-sm-6">
<label>
<input placeholder="Appointment Time" type="text"
onfocus="(this.type='time')" class="form-control"
name="appointmenttime" id="appointmenttime"><i
class="ion-ios-clock"></i>
</label>
</li>
<li class="col-sm-6">
<label>
<select name="department" class="selectpicker" id="department"
>
<option value="">Select Department</option>
<?php
$sqldept = "SELECT * FROM department WHERE status='Active'";
$qsqldept = mysqli_query($con,$sqldept);
while($rsdept = mysqli_fetch_array($qsqldept))
{
echo "<option value='$rsdept[departmentid]'>$rsdept[departmentname]</option>";
}
?>
</select>
<i class="ion-university"></i>
</label>
</li>
<li class="col-sm-6">
<label>
<select name="doct" class="selectpicker" id="department"
>
<option value="">Select Doctor</option>
<?php
$sqldept = "SELECT * FROM doctor WHERE status='Active'";
$qsqldept = mysqli_query($con,$sqldept);
while($rsdept = mysqli_fetch_array($qsqldept))
{
echo "<option value='$rsdept[doctorid]'>$rsdept[doctorname] (";
$sqldept = "SELECT * FROM department WHERE departmentid='$rsdept[departmentid]'";
$qsqldepta = mysqli_query($con,$sqldept);
$rsdept = mysqli_fetch_array($qsqldepta);
echo $rsdept['departmentname'];
echo ")</option>";
}
?>
</select>
<i class="ion-medkit"></i>
</label>
</li>
<li class="col-sm-12">
<label>
<textarea class="form-control" name="app_reason"
placeholder="Appointment reason"></textarea>
</label>
</li>
<li class="col-sm-12">
<button type="submit" class="btn" name="submit" id="submit">make an
appointment</button>
</li>
</form>
</div>
</div>
</div>
</div>
<?php
}
?>
</div>
</div>
</div>
</section>
</div>
<?php
include("footer.php");
?>
<script type="application/javascript">
var alphaExp = /^[a-zA-Z]+$/; //Variable to validate only alphabets
var alphaspaceExp = /^[a-zA-Z\s]+$/; //Variable to validate only alphabets and space
var numericExpression = /^[0-9]+$/; //Variable to validate only numbers
var alphanumericExp = /^[0-9a-zA-Z]+$/; //Variable to validate numbers and alphabets
var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/; //Variable to validate Email ID
function validateform() {
if (document.frmpatapp.patiente.value == "") {
alert("Patient name should not be empty..");
document.frmpatapp.patiente.focus();
return false;
} else if (!document.frmpatapp.patiente.value.match(alphaspaceExp)) {
alert("Patient name not valid..");
document.frmpatapp.patiente.focus();
return false;
} else if (document.frmpatapp.textarea.value == "") {
alert("Address should not be empty..");
document.frmpatapp.textarea.focus();
return false;
} else if (document.frmpatapp.city.value == "") {
alert("City should not be empty..");
document.frmpatapp.city.focus();
return false;
} else if (!document.frmpatapp.city.value.match(alphaspaceExp)) {
alert("City name not valid..");
document.frmpatapp.city.focus();
return false;
} else if (document.frmpatapp.mobileno.value == "") {
alert("Mobile number should not be empty..");
document.frmpatapp.mobileno.focus();
return false;
} else if (!document.frmpatapp.mobileno.value.match(numericExpression)) {
alert("Mobile number not valid..");
document.frmpatapp.mobileno.focus();
return false;
} else if (document.frmpatapp.loginid.value == "") {
alert("login ID should not be empty..");
document.frmpatapp.loginid.focus();
return false;
} else if (!document.frmpatapp.loginid.value.match(emailExp)) {
alert("login ID not valid..");
document.frmpatapp.loginid.focus();
return false;
} else if (document.frmpatapp.password.value == "") {
alert("Password should not be empty..");
document.frmpatapp.password.focus();
return false;
} else if (document.frmpatapp.password.value.length < 8) {
alert("Password length should be more than 8 characters...");
document.frmpatapp.password.focus();
return false;
} else if (document.frmpatapp.select6.value == "") {
alert("Gender should not be empty..");
document.frmpatapp.select6.focus();
return false;
} else if (document.frmpatapp.dob.value == "") {
alert("Date Of Birth should not be empty..");
document.frmpatapp.dob.focus();
return false;
} else if (document.frmpatapp.appointmentdate.value == "") {
alert("Appointment date should not be empty..");
document.frmpatapp.appointmentdate.focus();
return false;
} else if (document.frmpatapp.appointmenttime.value == "") {
alert("Appointment time should not be empty..");
document.frmpatapp.appointmenttime.focus();
return false;
} else {
return true;
}
}
function loaddoctor(deptid) {
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
} else {
// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("divdoc").innerHTML = this.responseText;
}
};
xmlhttp.open("GET", "departmentDoctor.php?deptid=" + deptid, true);
xmlhttp.send();
}
</script>