-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathappointmentapproval.php
220 lines (208 loc) · 6.48 KB
/
appointmentapproval.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
<?php
include("adheader.php");
include("dbconnection.php");
if(isset($_POST[submit]))
{
if(isset($_GET[editid]))
{
$sql ="UPDATE patient SET status='Active' WHERE patientid='$_GET[patientid]'";
$qsql=mysqli_query($con,$sql);
$roomid=0;
$sql ="UPDATE appointment SET appointmenttype='$_POST[apptype]',departmentid='$_POST[select5]',doctorid='$_POST[select6]',status='Approved',appointmentdate='$_POST[appointmentdate]',appointmenttime='$_POST[time]' WHERE appointmentid='$_GET[editid]'";
if($qsql = mysqli_query($con,$sql))
{
$roomid= $_POST[select3];
$billtype = "Room Rent";
include("insertbillingrecord.php");
echo "<script>alert('appointment record updated successfully...');</script>";
echo "<script>window.location='patientreport.php?patientid=$_GET[patientid]&appointmentid=$_GET[editid]';</script>";
}
else
{
echo mysqli_error($con);
}
}
else
{
$sql ="UPDATE patient SET status='Active' WHERE patientid='$_POST[select4]'";
$qsql=mysqli_query($con,$sql);
$sql ="INSERT INTO appointment(appointmenttype,patientid,roomid,departmentid,appointmentdate,appointmenttime,doctorid,status) values('$_POST[select2]','$_POST[select4]','$_POST[select3]','$_POST[select5]','$_POST[appointmentdate]','$_POST[time]','$_POST[select6]','$_POST[select]')";
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);
}
?>
<div class="card ">
<div class="block-header">
<h2 class="text-center">Appointment Approval Process</h2>
</div>
<form method="post" action="" name="frmappnt" onSubmit="return validateform()">
<table class="table table-striped">
<tr>
<td >Patient</td>
<td >
<?php
if(isset($_GET[patientid]))
{
$sqlpatient= "SELECT * FROM patient WHERE patientid='$_GET[patientid]'";
$qsqlpatient = mysqli_query($con,$sqlpatient);
$rspatient=mysqli_fetch_array($qsqlpatient);
echo $rspatient[patientname] . " (Patient ID - $rspatient[patientid])";
}
else
{
$sqlpatient= "SELECT * FROM patient WHERE status='Active'";
$qsqlpatient = mysqli_query($con,$sqlpatient);
while($rspatient=mysqli_fetch_array($qsqlpatient))
{
if($rspatient[patientid] == $rsedit[patientid])
{
echo "<option value='$rspatient[patientid]' selected> $rspatient[patientname](Patient ID - $rspatient[patientid])</option>";
}
}
}
?>
</td>
</tr>
<tr>
<td>Department</td>
<td><select name="select5" id="select5" class="form-control show-tick">
<option value="">Select</option>
<?php
$sqldepartment= "SELECT * FROM department WHERE status='Active'";
$qsqldepartment = mysqli_query($con,$sqldepartment);
while($rsdepartment=mysqli_fetch_array($qsqldepartment))
{
if($rsdepartment[departmentid] == $rsedit[departmentid])
{
echo "<option value='$rsdepartment[departmentid]' selected>$rsdepartment[departmentname]</option>";
}
else
{
echo "<option value='$rsdepartment[departmentid]'>$rsdepartment[departmentname]</option>";
}
}
?>
</select></td>
</tr>
<tr>
<td>Doctor</td>
<td><select name="select6" id="select6" class="form-control show-tick">
<option value="">Select</option>
<?php
$sqldoctor= "SELECT * FROM doctor INNER JOIN department ON department.departmentid=doctor.departmentid WHERE doctor.status='Active'";
$qsqldoctor = mysqli_query($con,$sqldoctor);
while($rsdoctor = mysqli_fetch_array($qsqldoctor))
{
if($rsdoctor[doctorid] == $rsedit[doctorid])
{
echo "<option value='$rsdoctor[doctorid]' selected>$rsdoctor[doctorname] ( $rsdoctor[departmentname] ) </option>";
}
else
{
echo "<option value='$rsdoctor[doctorid]'>$rsdoctor[doctorname] ( $rsdoctor[departmentname] )</option>";
}
}
?>
</select></td>
</tr>
<tr>
<td>Appointment Date</td>
<td><input class="form-control" type="date" name="appointmentdate" id="appointmentdate" value="<?php echo $rsedit[appointmentdate]; ?>" /></td>
</tr>
<tr>
<td>Appointment Time</td>
<td><input class="form-control" type="time" name="time" id="time" value="<?php echo $rsedit[appointmenttime]; ?>" /></td>
</tr>
<tr>
<td>Appointment reason</td>
<td><input class="form-control" name="appreason" id="appreason" value="<?php echo $rsedit[app_reason]; ?>"/></td>
</tr>
<tr>
<td colspan="2" align="center"><input class="btn btn-default" type="submit" name="submit" id="submit" value="Submit" /></td>
</tr>
</tbody>
</table>
</form>
<p> </p>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<?php
include("adfooter.php");
?>
<script type="application/javascript">
function validateform()
{
if(document.frmappnt.select4.value == "")
{
alert("Patient name should not be empty..");
document.frmappnt.select4.focus();
return false;
}
else if(document.frmappnt.select3.value == "")
{
alert("Room type should not be empty..");
document.frmappnt.select3.focus();
return false;
}
else if(document.frmappnt.select5.value == "")
{
alert("Department name should not be empty..");
document.frmappnt.select5.focus();
return false;
}
else if(document.frmappnt.appointmentdate.value == "")
{
alert("Appointment date should not be empty..");
document.frmappnt.appointmentdate.focus();
return false;
}
else if(document.frmappnt.time.value == "")
{
alert("Appointment time should not be empty..");
document.frmappnt.time.focus();
return false;
}
else if(document.frmappnt.select6.value == "")
{
alert("Doctor name should not be empty..");
document.frmappnt.select6.focus();
return false;
}
else if(document.frmappnt.select.value == "" )
{
alert("Kindly select the status..");
document.frmappnt.select.focus();
return false;
}
else
{
return true;
}
}
$('.out_patient').hide();
$('#apptype').change(function()
{
apptype=$('#apptype').val();
if(apptype=='InPatient')
{
$('.out_patient').show();
}
else
{
$('.out_patient').hide();
}
});
</script>