-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpatient-history.php
300 lines (246 loc) · 13.3 KB
/
patient-history.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
<?php
session_start();
?>
<?php require_once 'header.php'; ?>
<?php require_once 'sidebar.php'; ?>
<div id="page-content-wrapper">
<div class="container-fluid">
<div class="row">
<!--Find show all visit records-->
<?php if(isset($_GET['action']) && $_GET['action']=='single'):?>
<div class="col-md-12">
<?php
$q="select patient_id, fname,lname,mobileno from patient where patient_id={$_POST['searchVal']}";
$patientArr=$db->query($q);
$no=0;
$no=count($patientArr);
if($no==0):
?>
<h3>No Result Found</h3>
<?php else:
$q="select visit_rec_id,time_in,time_out from visit_record where patient_id={$_POST['searchVal']} order by visit_rec_id desc";
$visitArr=$db->query($q);
$no=0;
$no=count($visitArr);
$i=0;
$x=$no-1;
?>
<h1>Medical Record</h1>
<div class="row statsboxes">
<div class="stats_title clearfix"><span class="pull-left">Patient Stats:</span><span class="pull-right">Total No Of Visits: <?php echo "{$no}" ?> </span></div>
<div class="col-md-3 statsbox">
<h3>Patient Id:</h3>
<div class="stats_content">
<?php echo "{$_POST['searchVal']}" ?>
</div>
</div>
<div class="col-md-3 statsbox statsbox_doc">
<h3>Name:</h3>
<div class="stats_content">
<?php echo "{$patientArr[$i]['fname']} {$patientArr[$i]['lname']}" ?>
</div>
</div>
<div class="col-md-3 statsbox">
<h3>Medical Record No:</h3>
<div class="stats_content">
10
</div>
</div>
<div class="col-md-3 statsbox">
<h3>Mobile No:</h3>
<div class="stats_content">
<?php echo "{$patientArr[$i]['mobileno']}" ?>
</div>
</div>
</div>
</div>
</div>
</div>
<?php
while($i<$no){ ?>
<div id="page-content-wrapper">
<div class="container-fluid">
<div class="col-md-12">
<div class="row statsboxes">
<div class="stats_title clearfix"><span class="pull-left">Visit Record <?php echo $x+1 ?>:</span><button type="button" class="btn btn-info btn-lg pull-right" data-toggle="modal" data-target="#myModal<?php echo $i; ?>">View Prescription</button></div>
<div id="myModal<?php echo $i; ?>" class="modal fade" role="dialog">
<div class="modal-dialog">
<?php
$q="select remarks,disease from precription_rec where visit_rec_id={$visitArr[$i]['visit_rec_id']}";
$presc=$db->query($q);
$q="select med.med_name,pm.recommendation,pr.presc_id from precription_rec pr,presc_med pm,medicine med where (pr.presc_id=pm.presc_id) and (pm.med_id=med.med_id) and pr.visit_rec_id={$visitArr[$i]['visit_rec_id']}";
$med=$db->query($q);
$c=0;
$c=count($med);
$j=0;
?>
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header" style="background-color:#292f3b;color:white;">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Prescription:</h4>
</div>
<div class="modal-body">
<h4><b><strong>Remarks:</strong></b></h4>
<p><?php echo (count($presc) > 0) ? '<b>' . $presc[0]['remarks'] . '</b>' : '<div class="alert alert-warning">Not entered</div>'; ?></p>
<h4><b><strong>Disease:</strong></b></h4>
<p><?php echo (count($presc) > 0) ? '<b>' . $presc[0]['disease'] . '</b>' : '<div class="alert alert-warning">Not mentioned</div>'; ?></p>
<h4><b><strong>Medicines:</strong></b></h4>
<?php
if(count($med) > 0){
while($j<$c){ ?>
<p><b><?php echo $j+1 ?><?php echo ". {$med[$j]['med_name']} {$med[$j]['recommendation']}" ?></b></p>
<?php
$j++;
}
} else {
echo '<div class="alert alert-warning">No medicine entered</div>';
}
?>
</div>
<div class="modal-footer">
<a href="patient-history.php?action=edit&id=<?php echo $visitArr[$i]['visit_rec_id'] ?>" class="btn btn-lg btn-success">Edit</a>
<button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<div class="col-md-6 statsbox">
<h3>Date In:</h3>
<div class="stats_content">
<?php echo "{$visitArr[$i]['time_in']}" ?>
</div>
</div>
<div class="col-md-6 statsbox">
<h3>Time In:</h3>
<div class="stats_content">
<?php echo "{$visitArr[$i]['time_in']}" ?>
</div>
</div>
<div class="col-md-6 statsbox">
<h3>Date Out:</h3>
<div class="stats_content">
<?php echo "{$visitArr[$i]['time_out']}" ?>
</div>
</div>
<div class="col-md-6 statsbox">
<h3>Time Out:</h3>
<div class="stats_content">
<?php echo "{$visitArr[$i]['time_in']}" ?>
</div>
</div>
</div>
</div>
</div>
</div>
<?php
$x--;
$i++;
} ?>
<?php endif; ?>
<!-- Edit Prescription -->
<?php elseif(isset($_GET['action']) && $_GET['action']=='edit'):?>
<div class="col-md-12">
<?php
$q="select remarks,disease from precription_rec where visit_rec_id={$_GET['id']}";
$presc=$db->query($q);
$q="select med.med_name,pm.med_id,pm.recommendation,pr.presc_id from precription_rec pr,presc_med pm,medicine med where (pr.presc_id=pm.presc_id) and (pm.med_id=med.med_id) and pr.visit_rec_id={$_GET['id']}";
$med=$db->query($q);
$c=0;
$c=count($med);
$i=0;
$q="select med_id,med_name from medicine";
$all_med=$db->query($q);
$t=0;
$t=count($all_med);
$countMeds=0;
?>
<h3 class="formdiv2">Edit Prescription for Patient ID <?php echo $db->cleanString($_GET['id']); ?>:</h3>
<form id="myform" action="patient-history.php?action=edit&id=<?php echo $_GET['id']; ?>" method="post">
<p class="formdiv2"><b>Disease:</b></p>
<div class="formdiv2 input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-align-justify"></i></span>
<input id="text" type="text" class="form-control" name="disease" placeholder="Disease" value="<?php echo (count($presc) > 0) ? $presc[0]['disease'] : ''; ?>" required>
</div>
<p class="formdiv2"><b>Remarks:</b></p>
<div class="formdiv2 input-group" >
<span class="input-group-addon"><i class="glyphicon glyphicon-align-justify"></i></span>
<input id="text rem" type="text" class="form-control" name="remarks" placeholder="Remarks" value="<?php echo (count($presc) > 0) ? $presc[0]['remarks'] : ''; ?>">
</div>
<?php
while($i<$c)
{
$countMeds++;
?>
<div class="formdiv2 input-group">
<label for="sel1" style="margin-left:5px">Medicine <?php echo $i+1 ?>:</label>
<select class="form-control" id="sel1" name="med<?php echo $countMeds ?>" required>
<?php
$j=0;
while($j<$t){
$selected=$med[$i]['med_id'] ==$all_med[$j]['med_id'] ? 'selected': '';
?>
<option value="<?php echo $all_med[$j]['med_id'] ?>" <?php echo $selected ?>><?php echo $all_med[$j]['med_name'] ?></option>
<?php
$j++; } ?>
</select>
</div>
<div class="formdiv2 input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-align-justify"></i></span>
<input id="text" type="text" class="form-control" name="rec<?php echo $countMeds ?>" placeholder="Recommendation" value="<?php echo $med[0]['recommendation']; ?>" required>
</div>
<?php
$i++;
}
?>
<div id="room_fileds" >
</div>
<div class="formdiv2 input-group">
<button class="btn btn-default" type="button" id="more_fields" onclick="add_fields();" value="" ><i class="glyphicon glyphicon-plus"></i> Add Medicine</button>
</div>
<br>
<div class="formdiv2 input-group">
<button class="btn btn-warning btn-lg" type="submit" onclick="setAction()" name="update_presc">Update</button>
</div>
</form>
</div>
</div>
<!--Update Prescription Data-->
<?php elseif(isset($_POST['update_presc'])):
$q="select presc_id from precription_rec where visit_rec_id={$_GET['id']}";
$presc=$db->query($q);
var_dump( $presc);
$q="update precription_rec set remarks='{$_POST['disease']}',disease='{$_POST['remarks']}' where visit_rec_id={$_GET['id']}";
$db->query($q,true);
if(count($presc) > 0) {
$q="delete from presc_med where presc_id={$presc[0]['presc_id']}";
$db->query($q,true);
$i=1;
$count=$_GET['meds'];
while($i<=$count)
{
$q="insert into presc_med (presc_id,recommendation,med_id) value ('{$presc[0]['presc_id']}'','{$_POST['rec'.$i]}',{$_POST['med'.$i]})";
$db->query($q,true);
$i++;
}
}
echo '<div class="alert alert-success">Prescription Updated Successfully</div>';
?>
<?php else: require_once 'forms/search_patient.php'; ?>
<?php endif; ?>
<?php require_once 'footer.php'; ?>
<script>
var med = <?php echo $i ?>;
var n= <?php echo $countMeds ?>;
function add_fields() {
med++;
n++;
var objTo = document.getElementById('room_fileds')
var divtest = document.createElement("div");
divtest.innerHTML = '<div class="formdiv2 input-group"><label for="sel1" style="margin-left:5px">Medicine ' +med+ ':</label><select class="form-control" id="sel1" name="med'+n+'" required><option selected></opton><?php $j=0; while($j<$t){ ?> <option value="<?php echo $all_med[$j]['med_id'] ?>"><?php echo $all_med[$j]['med_name'] ?></option> <?php $j++; } ?> </select></div><div class="formdiv2 input-group"><span class="input-group-addon"><i class="glyphicon glyphicon-align-justify"></i></span><input id="text" type="text" class="form-control" name="rec'+n+'" placeholder="Recommendation" value="" required></div>';
objTo.appendChild(divtest)
}
function setAction(){
document.getElementById('myform').action= 'patient-history.php?action=update&id=<?php echo $_GET['id'] ?>&meds='+med+'';
}
</script>