-
Notifications
You must be signed in to change notification settings - Fork 0
/
welcome.php
1467 lines (1321 loc) · 80 KB
/
welcome.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
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>HealthMate</title>
<!-- Bootstrap core CSS -->
<link href="newcss/bootstrap.css" type="text/css" rel="stylesheet">
<!-- Custom CSS for welcome page -->
<link href="newcss/welcome.css" type="text/css" rel="stylesheet">
<!-- Charts.js for graphs -->
<script src="Chart.min.js"></script>
<?php
// Grab security functions
require_once("/private/initialize.php");
session_start();
// Make sure the session is still active
validate_user_before_displaying();
$username = $_SESSION["username"];
// Check if logout button was pressed
if (isset($_POST['logout'])) {
after_successful_logout();
echo header("Location: /HealthMateTest/index.php");
}
$patient_info = "";
// Only process POST requests, not GET
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// Create connection
$conn = new mysqli(DB_SERVER, DB_USER, DB_PASS, DB_NAME);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// For now, all patients will be shown (table needs to be re-designed
$sql = "SELECT * FROM patient WHERE group_id = 2";
$result = $conn->query($sql);
// Generate the proper HTML elements and display
// all the patient info
if ($result->num_rows > 0) {
// output each row
while ($row = $result->fetch_assoc()) {
$patient_info .= "<section class='container'>";
$patient_info .= "<div class='login'>";
$patient_info .= "Patient ID: " . $row["patient_id"] . "<br />";
$patient_info .= "First name: " . $row["first_name"] . "<br />";
$patient_info .= "Last name: " . $row["last_name"] . "<br />";
$patient_info .= "Gender: " . $row["gender"] . "<br />";
$patient_info .= "Birthday: " . $row["birthday"] . "<br />";
$patient_info .= "</div>";
$patient_info .= "</section>";
}
} else {
echo "Error: " . $sql . "<br />" . $conn->error;
}
// Peace out
$conn->close();
}
?>
</head>
<body>
<!-- begin navigation bar -->
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/HealthMateTest/welcome.php">HealthMate</a>
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-2">
<ul class="nav navbar-nav">
<li class="active"><a id="home-link" href="/HealthMateTest/welcome.php">Home<span class="sr-only">(current)</span></a></li>
<li id="view-patient" class="dropdown">
<a href="#" class="dropdown-toggle view-patient" data-toggle="dropdown" role="button" aria-expanded="false">Patient <span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li><a id="add-patient" href="#">Add Patient</a></li>
<li class="divider"></li>
<li><a id="view-patient-list" href="#">View Patient List</a></li>
</ul>
</li>
<!-- Appointments navigation and dropdown -->
<li id="view-appointment" class="dropdown">
<a href="#" class="dropdown-toggle view-patient" data-toggle="dropdown" role="button" aria-expanded="false">Appointments <span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li><a id="create-appointment" href="#">Create Appointment</a></li>
<li class="divider"></li>
<li id="view-appointment-list"><a href="#">View Appointments</a></li>
</ul>
</li>
<!-- End of Appointments navigation and dropdown -->
<!-- Medications navigation and dropdown -->
<li id="view-medication" class="dropdown">
<a href="#" class="dropdown-toggle view-patient" data-toggle="dropdown" role="button" aria-expanded="false">Medications <span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li><a id="add-medication" href="#">Add Medication</a></li>
<li class="divider"></li>
<li id="view-medication-list"><a href="#">View Medications</a></li>
<li class="divider"></li>
<li id="assign-medication"><a href="#">Assign Medication</a></li>
</ul>
</li>
<!-- End of Medications navigation and dropdown -->
<li id="data"><a href="#">Data</a></li>
<li><a href="/HealthMateTest/account_settings.php">Settings</a></li>
<li><a href="/HealthMateTest/logout.php">Logout</a></li>
</ul>
</div>
</div>
</nav>
<!-- end navigation bar -->
<div class="progress progress-striped active hidden" id="progdiv" style="margin-top: -20px;">
<div class="progress-bar" id="progbar" style="width: 0%"></div>
</div>
<div class="jumbotron welcome-jumbo hidden" id="welcome-jumbo">
<!-- Contains the welcome information -->
<div class="container" id="welcome-container">
<div class="alert alert-dismissible alert-info">
<button type="button" class="close" data-dismiss="alert">×</button>
<span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span><strong> Warning!</strong>
Please note that HealthMate is currently being developed so some functionality may be missing!
</div>
<h1>Welcome, <span id="doctor_id"><?php echo $username; ?></span>!</h1>
<div class="panel panel-default">
<div class="panel-body">
This is the HealthMate welcome page. From here you can view your patient list, modify patient information, change your settings, and more!
</div>
</div>
</div>
<!-- End of welcome -->
<!-- Add patient form -->
<div class="panel panel-default hidden" id="add-patient-panel">
<div class="panel-body">
<h3 class="text-center">Patient Form</h3>
<fieldset>
<form role="form" id="add-patient-form" class="form-horizontal login-form" method="post">
<div class="form-group" id="username-input">
<div class="col-md-12">
<label>Patient Username:</label>
<div class="input-group">
<span class="input-group-addon"><span class="glyphicon glyphicon-user"></span></span>
<input type="username" id="username" name="username" class="form-control" data-container="body" data-toggle="popover" data-trigger="focus" data-content="8 - 16 alphanumeric characters" data-parsley-required="true" data-parsley-type="alphanum" data-parsley-length="[8, 16]" data-parsley-group="block1" data-parsley-ui-enabled="false">
</div>
</div>
</div>
<div class="form-group" id="first-name-input">
<div class="col-md-12">
<label>Patient First Name:</label>
<div class="input-group">
<span class="input-group-addon"><span class="glyphicon">FN</span></span>
<input type="text" id="first_name" name="first_name" class="form-control" data-parsley-required="true" data-parsley-group="block2" data-parsley-ui-enabled="false">
</div>
</div>
</div>
<div class="form-group" id="last-name-input">
<div class="col-md-12">
<label>Patient Last Name:</label>
<div class="input-group">
<span class="input-group-addon"><span class="glyphicon">LN</span></span>
<input type="text" id="last_name" name="last_name" class="form-control" data-parsley-required="true" data-parsley-group="block3" data-parsley-ui-enabled="false">
</div>
</div>
</div>
<div class="form-group" id="age-input">
<div class="col-md-12">
<div class="input-group" style="padding-top: 15px;">
<label>Patient Gender:</label>
<select name="gender" id="gender" class="form-control-static" style="margin-left: 15px;">
<option>Male</option>
<option>Female</option>
<option>Other</option>
</select>
</div>
<div class="input-group">
<label>Patient Birthday:</label>
<input type="date" id="birthday" style="margin-top: 15px; margin-left: 15px;">
</div>
</div>
<div class="col-md-12" style="margin-top: 5%;">
<button type="submit" id="add-patient-button" class="btn btn-lg btn-block btn-primary validate">Add Patient</button>
</div>
</div>
</form>
</fieldset>
</div>
</div>
<!-- End of add patient -->
<!-- Create Appointment Form -->
<div class="panel panel-default hidden" id="create-appointment-panel">
<div class="panel-body">
<h3 class="text-center">Appointment Form</h3>
<fieldset>
<form role="form" id="create-appointment-form" class="form-horizontal login-form" method="post">
<div class="form-group" id="appointment-username-input">
<div class="col-md-12">
<label>Patient Username:</label><br />
<select name="appointment_username" id="appointment_username" class="form-control" data-parsley-required="true" data-parsley-group="block14" data-parsley-ui-enabled="false">
<option selected disabled>Select a Patient</option>
<option>Other</option>
<?php
// Create connection
$conn = new mysqli(DB_SERVER, DB_USER, DB_PASS, DB_NAME);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Select all patients that are associated with this doctor
//$sql = "SELECT * FROM patient WHERE doctor_id =" . $username ."";
$sql = "SELECT * FROM patient WHERE doctor_id = '".$username."'";
// Execute Query
$result = $conn->query($sql);
// Create a selectable option for each patient associated
// with the current doctor
foreach($result as $row) {
$patient_username = $row["username"];
$first_name = $row["first_name"];
$last_name = $row["last_name"];
echo "<option>{$first_name}, {$last_name} ({$patient_username})</option>";
}
?>
</select>
</div>
</div>
<div class="form-group" id="appointment-first-name-input">
<div class="col-md-12">
<label>Patient First Name:</label>
<div class="input-group">
<span class="input-group-addon"><span class="glyphicon">FN</span></span>
<input type="text" id="appointment_first_name" name="appointment_first_name" class="form-control" data-parsley-required="true" data-parsley-group="block4" data-parsley-ui-enabled="false">
</div>
</div>
</div>
<div class="form-group" id="appointment-last-name-input">
<div class="col-md-12">
<label>Patient Last Name:</label>
<div class="input-group">
<span class="input-group-addon"><span class="glyphicon">LN</span></span>
<input type="text" id="appointment_last_name" name="appointment_last_name" class="form-control" data-parsley-required="true" data-parsley-group="block5" data-parsley-ui-enabled="false">
</div>
</div>
</div>
<div class="form-group" id="appointment-title-input">
<div class="col-md-12">
<label>Appointment Title:</label>
<div class="input-group">
<span class="input-group-addon"><span class="glyphicon">T</span></span>
<input type="text" id="appointment_title" name="appointment_title" class="form-control" data-parsley-required="true" data-parsley-group="block6" data-parsley-ui-enabled="false">
</div>
</div>
</div>
<div class="form-group" id="appointment-address-input">
<div class="col-md-12">
<label>Address:</label>
<div class="input-group">
<span class="input-group-addon"><span class="glyphicon glyphicon-envelope"></span></span>
<input type="text" id="appointment_address" name="appointment_address" class="form-control" data-parsley-required="true" data-parsley-group="block7" data-parsley-ui-enabled="false">
</div>
</div>
</div>
<div class="form-group" id="appointment-city-input">
<div class="col-md-12">
<label>City:</label>
<div class="input-group">
<span class="input-group-addon"><span class="glyphicon glyphicon-envelope"></span></span>
<input type="text" id="appointment_city" name="appointment_city" class="form-control" data-parsley-required="true" data-parsley-group="block8" data-parsley-ui-enabled="false">
</div>
</div>
</div>
<div class="form-group" id="appointment-zipcode-input">
<div class="col-md-12">
<label>Zip Code:</label>
<div class="input-group">
<span class="input-group-addon"><span class="glyphicon glyphicon-envelope"></span></span>
<input type="text" id="appointment_zipcode" name="appointment_zipcode" class="form-control" data-container="body" data-toggle="popover" data-trigger="focus" data-content="5 - 9 numerical characters (no spaces)" data-parsley-required="true" data-parsley-type="number" data-parsley-length="[5, 9]" data-parsley-group="block9" data-parsley-ui-enabled="false">
</div>
</div>
</div>
<div class="form-group" id="appointment-state-input">
<div class="col-md-12">
<label>State:</label>
<div class="input-group">
<span class="input-group-addon"><span class="glyphicon glyphicon-globe"></span></span>
<!-- <input type="text" id="appointment_state" name="appointment_state" class="form-control" data-parsley-required="true" data-parsley-group="block10" data-parsley-ui-enabled="false">-->
<select class="ui search dropdown form-control" id="appointment_state" name="appointment_state" data-parsley-required="true" data-parsley-group="block10" data-parsley-ui-enabled="false">
<option value="">State</option>
<option value="AL">Alabama</option>
<option value="AL">Alabama</option>
<option value="AK">Alaska</option>
<option value="AZ">Arizona</option>
<option value="AR">Arkansas</option>
<option value="CA">California</option>
<option value="CO">Colorado</option>
<option value="CT">Connecticut</option>
<option value="DE">Delaware</option>
<option value="DC">District Of Columbia</option>
<option value="FL">Florida</option>
<option value="GA">Georgia</option>
<option value="HI">Hawaii</option>
<option value="ID">Idaho</option>
<option value="IL">Illinois</option>
<option value="IN">Indiana</option>
<option value="IA">Iowa</option>
<option value="KS">Kansas</option>
<option value="KY">Kentucky</option>
<option value="LA">Louisiana</option>
<option value="ME">Maine</option>
<option value="MD">Maryland</option>
<option value="MA">Massachusetts</option>
<option value="MI">Michigan</option>
<option value="MN">Minnesota</option>
<option value="MS">Mississippi</option>
<option value="MO">Missouri</option>
<option value="MT">Montana</option>
<option value="NE">Nebraska</option>
<option value="NV">Nevada</option>
<option value="NH">New Hampshire</option>
<option value="NJ">New Jersey</option>
<option value="NM">New Mexico</option>
<option value="NY">New York</option>
<option value="NC">North Carolina</option>
<option value="ND">North Dakota</option>
<option value="OH">Ohio</option>
<option value="OK">Oklahoma</option>
<option value="OR">Oregon</option>
<option value="PA">Pennsylvania</option>
<option value="RI">Rhode Island</option>
<option value="SC">South Carolina</option>
<option value="SD">South Dakota</option>
<option value="TN">Tennessee</option>
<option value="TX">Texas</option>
<option value="UT">Utah</option>
<option value="VT">Vermont</option>
<option value="VA">Virginia</option>
<option value="WA">Washington</option>
<option value="WV">West Virginia</option>
<option value="WI">Wisconsin</option>
<option value="WY">Wyoming</option>
</select>
</div>
</div>
</div>
<div class="form-group" id="appointment-date-input">
<div class="col-md-12">
<div class="input-group">
<label>Date:</label>
<input type="date" id="appointment_date" style="margin-top: 15px; margin-left: 15px;" class="form-control" data-container="body" data-toggle="popover" data-trigger="focus" data-content="Date must be later than current Date" data-parsley-required="true" data-parsley-group="block11" data-parsley-ui-enabled="false">
</div>
</div>
</div>
<div class="form-group" id="appointment-starttime-input">
<div class="col-md-12">
<div class="input-group">
<label>Start Time:</label>
<input type="time" id="appointment_start_time" style="margin-top: 15px; margin-left: 15px;" class="form-control" data-container="body" data-toggle="popover" data-trigger="focus" data-content="Start Time must be before End Time" data-parsley-required="true" data-parsley-group="block12" data-parsley-ui-enabled="false">
</div>
</div>
</div>
<div class="form-group" id="appointment-endtime-input">
<div class="col-md-12">
<div class="input-group">
<label>End Time:</label>
<input type="time" id="appointment_end_time" style="margin-top: 15px; margin-left: 15px;" class="form-control" data-container="body" data-toggle="popover" data-trigger="focus" data-content="End Time must be after Start Time" data-parsley-required="true" data-parsley-group="block13" data-parsley-ui-enabled="false">
</div>
</div>
</div>
<div class="col-md-12" style="margin-top: 5%;">
<button type="submit" id="create-appointment-button" class="btn btn-lg btn-block btn-primary validate">Create Appointment</button>
</div>
</div>
</form>
</fieldset>
</div>
<!-- End of create appointment form -->
<!-- Start of Medication Form -->
<div class="panel panel-default hidden" id="add-medication-panel">
<div class="panel-body">
<h3 class="text-center">Medication Form</h3>
<fieldset>
<form role="form" id="add-medication-form" class="form-horizontal login-form" method="post">
<div class="form-group" id="medication-name-input">
<div class="col-md-12">
<label>Medication Name:</label>
<div class="input-group">
<span class="input-group-addon"><span class="glyphicon">MD</span></span>
<input type="text" id="medication_name" name="medication_name" class="form-control" data-parsley-required="true" data-parsley-group="block14" data-parsley-ui-enabled="false">
</div>
</div>
</div>
<div class="form-group" id="medication-type-input">
<div class="col-md-12">
<label>Medication Type:</label>
<div class="input-group">
<span class="input-group-addon"><span class="glyphicon">T</span></span>
<input type="text" id="medication_type" name="medication_type" class="form-control" data-parsley-required="true" data-parsley-group="block15" data-parsley-ui-enabled="false">
</div>
</div>
</div>
<div class="form-group" id="intake-method-input">
<div class="col-md-12">
<label>Intake Method:</label>
<div class="input-group">
<span class="input-group-addon"><span class="glyphicon">IM</span></span>
<input type="text" id="intake_method" name="intake_method" class="form-control" data-parsley-required="true" data-parsley-group="block16" data-parsley-ui-enabled="false">
</div>
</div>
</div>
<div class="form-group" id="max-dosage-input">
<div class="col-md-12">
<label>Max Dosage:</label>
<div class="input-group">
<span class="input-group-addon"><span class="glyphicon">MAX</span></span>
<input type="text" id="max_dosage" name="max_dosage" class="form-control" data-parsley-required="true" data-parsley-group="block17" data-parsley-ui-enabled="false">
</div>
</div>
</div>
<div class="form-group" id="min-dosage-input">
<div class="col-md-12">
<label>Min Dosage:</label>
<div class="input-group">
<span class="input-group-addon"><span class="glyphicon">MIN</span></span>
<input type="text" id="min_dosage" name="min_dosage" class="form-control" data-parsley-required="true" data-parsley-group="block18" data-parsley-ui-enabled="false">
</div>
</div>
</div>
<div class="col-md-12" style="margin-top: 5%;">
<button type="submit" id="add-medication-button" class="btn btn-lg btn-block btn-primary validate">Add Medication</button>
</div>
</div>
</form>
</fieldset>
</div>
<!-- End of Medication Form -->
<!-- Medication Assign Form -->
<div class="panel panel-default hidden" id="assign-medication-panel">
<div class="panel-body">
<h3 class="text-center">Medication Assign Form</h3>
<fieldset>
<form role="form" id="assign-medication-form" class="form-horizontal login-form" method="post">
<div class="form-group" id="assign-medication-name-input">
<div class="col-md-12">
<label>Medication Name:</label><br />
<select name="assign_medication_name" id="assign_medication_name" class="form-control" data-parsley-required="true" data-parsley-group="block19" data-parsley-ui-enabled="false">
<option selected disabled>Select a Medication</option>
<?php
// Create connection
$conn = new mysqli(DB_SERVER, DB_USER, DB_PASS, DB_NAME);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Select all patients that are associated with this doctor
$sql = "SELECT * FROM medications";
// Execute Query
$result = $conn->query($sql);
// Create a selectable option for each patient associated
// with the current doctor
foreach($result as $row) {
$medication_name = $row["name"];
echo "<option>{$medication_name}</option>";
}
?>
</select>
</div>
</div>
<div class="form-group" id="assign-medication-patient-input">
<div class="col-md-12">
<label>Patient Username:</label><br />
<select name="assign_medication_patient" id="assign_medication_patient" class="form-control" data-parsley-required="true" data-parsley-group="block20" data-parsley-ui-enabled="false">
<option selected disabled>Select a Patient</option>
<?php
// Create connection
$conn = new mysqli(DB_SERVER, DB_USER, DB_PASS, DB_NAME);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Select all patients that are associated with this doctor
$sql = "SELECT * FROM patient WHERE doctor_id = '".$username."'";
// Execute Query
$result = $conn->query($sql);
// Create a selectable option for each patient associated
// with the current doctor
foreach($result as $row) {
$patient_username = $row["username"];
$first_name = $row["first_name"];
$last_name = $row["last_name"];
echo "<option value=\"{$patient_username}\">{$first_name}, {$last_name} ({$patient_username})</option>";
}
?>
</select>
</div>
</div>
<div class="form-group" id="assign-medication-patient-name-input">
<div class="col-md-12">
<label>Patient Name:</label>
<div class="input-group">
<span class="input-group-addon"><span class="glyphicon">PN</span></span>
<input type="text" id="assign_medication_patient_name" name="assign_medication_patient_name" class="form-control" data-parsley-required="true" data-parsley-group="block21" data-parsley-ui-enabled="false">
</div>
</div>
</div>
<div class="form-group" id="assign-medication-dosage-input">
<div class="col-md-12">
<label>Dosage:</label>
<div class="input-group">
<span class="input-group-addon"><span class="glyphicon">D</span></span>
<input type="text" id="assign_medication_dosage" name="assign_medication_dosage" class="form-control" data-parsley-required="true" data-parsley-group="block22" data-parsley-ui-enabled="false">
</div>
</div>
</div>
<div class="form-group" id="assign-medication-frequency-input">
<div class="col-md-12">
<label>Frequency:</label>
<div class="input-group">
<span class="input-group-addon"><span class="glyphicon">F</span></span>
<input type="text" id="assign_medication_frequency" name="assign_medication_frequency" class="form-control" data-parsley-required="true" data-parsley-group="block23" data-parsley-ui-enabled="false">
</div>
</div>
</div>
<div class="col-md-12" style="margin-top: 5%;">
<button type="submit" id="assign-medication-button" class="btn btn-lg btn-block btn-primary validate">Assign Medication</button>
</div>
</div>
</form>
</fieldset>
</div>
<!-- End of Medication Assign Form -->
<div id="myDiv" class="panel panel-default hidden"></div>
<div id="results" class="panel panel-default hidden"></div>
<div id="patient-profile" class="panel panel-default hidden"></div>
<div id="patient-graph" class="panel panel-default hidden"><h3 class="text-center">Monthly Steps Data</h3><canvas id="myChart" class="center-block"></canvas></div>
</div>
<!-- Bootstrap core JavaScript -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<!-- Form validation from Parsley -->
<script src="js/parsley.min.js"></script>
<script type="text/javascript">
function viewPatientProfile(patient_id) {
var xmlhttp;
if (window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();
}
xmlhttp.onreadystatechange = function () {
$("#progdiv").fadeIn(400).removeClass('hidden');
if (xmlhttp.readyState == 1) {
$("#progbar").css("width", "25%");
} else if (xmlhttp.readyState == 2) {
$("#progbar").css("width", "50%");
} else if (xmlhttp.readyState == 3) {
$("#progbar").css("width", "75%");
}
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
$("#progbar").css("width", "100%");
setTimeout(function() {
$("#progdiv").fadeOut(800).delay(400).addClass('hidden');
}, 1000);
// clear out the form and present the result
$("#welcome-container").fadeOut(400);
$("#add-patient-panel").fadeOut(400);
$("#create-appointment-panel").fadeOut(400);
$("#add-medication-panel").fadeOut(400);
$("#assign-medication-panel").fadeOut(400);
$("#patient-graph").fadeOut(400);
$("#welcome-jumbo").slideUp(400).delay(400).fadeIn(400);
setTimeout(function() {
$("#results").html(xmlhttp.responseText).fadeIn(400).removeClass('hidden');
}, 800);
// add onclick listeners to links
$('patient-id').click(function(e) {
viewPatientProfile(e);
});
}
};
var doc_id = $("#doctor_id").html();
xmlhttp.open("POST","viewpatientprofile.php",true);
// HTTP header required for POST
xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
xmlhttp.send("patient_id=" + patient_id + "&doctor_id=" + doc_id);
}
// handles the form submission and displays the results of
// adding a patient to the DB
function testAJAX() {
var xmlhttp;
if (window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();
}
xmlhttp.onreadystatechange = function () {
$("#progdiv").fadeIn(400).removeClass('hidden');
if (xmlhttp.readyState == 1) {
$("#progbar").css("width", "25%");
} else if (xmlhttp.readyState == 2) {
$("#progbar").css("width", "50%");
} else if (xmlhttp.readyState == 3) {
$("#progbar").css("width", "75%");
}
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
$("#progbar").css("width", "100%");
setTimeout(function() {
$("#progdiv").fadeOut(800).delay(400).addClass('hidden');
}, 1000);
// clear out the form and present the result
$("#welcome-container").fadeOut(400);
$("#add-patient-panel").fadeOut(400);
$("#patient-graph").fadeOut(400);
$("#welcome-jumbo").slideUp(400).delay(400).fadeIn(400);
$("#results").html(xmlhttp.responseText).fadeIn(800).removeClass('hidden');
}
};
var doc_id = $("#doctor_id").html();
var username = $("#username").val();
var first_name = $("#first_name").val();
var last_name = $("#last_name").val();
var gender = $("#gender").val();
var birthday = $("#birthday").val();
var password = "password321";
xmlhttp.open("POST","createaccount2.php",true);
// HTTP header required for POST
xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
xmlhttp.send("doctor_id=" + doc_id + "&username=" + username + "&first_name=" + first_name +
"&last_name=" + last_name + "&gender=" + gender + "&birthday=" + birthday + "&password=" + password);
}
// Submit Appointment Form Function
function submiteAppointmentWithAJAX() {
var xmlhttp;
if (window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();
}
xmlhttp.onreadystatechange = function () {
$("#progdiv").fadeIn(400).removeClass('hidden');
if (xmlhttp.readyState == 1) {
$("#progbar").css("width", "25%");
} else if (xmlhttp.readyState == 2) {
$("#progbar").css("width", "50%");
} else if (xmlhttp.readyState == 3) {
$("#progbar").css("width", "75%");
}
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
$("#progbar").css("width", "100%");
setTimeout(function() {
$("#progdiv").fadeOut(800).delay(400).addClass('hidden');
}, 1000);
// clear out the form and present the result
$("#create-appointment-panel").fadeOut(400);
$("#patient-graph").fadeOut(400);
$("#welcome-jumbo").slideUp(400).delay(400).fadeIn(400);
$("#results").html(xmlhttp.responseText).fadeIn(800).removeClass('hidden');
}
};
var appointment_username = $("#appointment_username").val();
// Doctor ID on my machine is underfined
// change when moved to host machine
//var doc_id = $("#doctor_id").html();
var doc_id = $("#doctor_id").html();
var first_name = $("#appointment_first_name").val();
var last_name = $("#appointment_last_name").val();
var appointment_title = $("#appointment_title").val();
var appointment_address = $("#appointment_address").val();
var appointment_city = $("#appointment_city").val();
var appointment_zipcode = $("#appointment_zipcode").val();
var appointment_state = $("#appointment_state").val();
var appointment_date = $("#appointment_date").val();
var appointment_start_time = $("#appointment_start_time").val();
var appointment_end_time = $("#appointment_end_time").val();
xmlhttp.open("POST","create_appointment.php",true);
// HTTP header required for POST
xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
xmlhttp.send("appointment_username=" + appointment_username + "&doctor_id=" + doc_id + "&first_name=" + first_name + "&last_name=" + last_name +
"&appointment_title=" + appointment_title + "&appointment_address=" + appointment_address + "&appointment_city=" + appointment_city +
"&appointment_zipcode=" + appointment_zipcode + "&appointment_state=" + appointment_state + "&appointment_date=" + appointment_date +
"&appointment_start_time=" + appointment_start_time + "&appointment_end_time=" + appointment_end_time);
}
// Display all Appointments to the user that are associated
// with there account Submit Function
function viewAppointmentsAJAX() {
var xmlhttp;
if (window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();
}
xmlhttp.onreadystatechange = function () {
$("#progdiv").fadeIn(400).removeClass('hidden');
if (xmlhttp.readyState == 1) {
$("#progbar").css("width", "25%");
} else if (xmlhttp.readyState == 2) {
$("#progbar").css("width", "50%");
} else if (xmlhttp.readyState == 3) {
$("#progbar").css("width", "75%");
}
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
$("#progbar").css("width", "100%");
setTimeout(function() {
$("#progdiv").fadeOut(800).delay(400).addClass('hidden');
}, 1000);
// clear out the form and present the result
$("#welcome-container").fadeOut(400);
$("#create-appointment-panel").fadeOut(400);
$("#add-medication-panel").fadeOut(400);
$("#assign-medication-panel").fadeOut(400);
$("#patient-graph").fadeOut(400);
$("#welcome-jumbo").slideUp(400).delay(400).fadeIn(400);
$("#results").html(xmlhttp.responseText).fadeIn(800).removeClass('hidden');
}
};
var doc_id = $("#doctor_id").html();
xmlhttp.open("POST","view_appointment_list.php",true);
// HTTP header required for POST
xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
xmlhttp.send("doctor_id=" + doc_id);
}
// grabs a list of all the patients this doctor manages
// from the database and displays them in the jumbotron
function viewPatientAJAX() {
var xmlhttp;
if (window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();
}
xmlhttp.onreadystatechange = function () {
$("#progdiv").fadeIn(400).removeClass('hidden');
if (xmlhttp.readyState == 1) {
$("#progbar").css("width", "25%");
} else if (xmlhttp.readyState == 2) {
$("#progbar").css("width", "50%");
} else if (xmlhttp.readyState == 3) {
$("#progbar").css("width", "75%");
}
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
$("#progbar").css("width", "100%");
setTimeout(function() {
$("#progdiv").fadeOut(800).delay(400).addClass('hidden');
}, 1000);
// clear out the form and present the result
$("#welcome-container").fadeOut(400);
$("#add-patient-panel").fadeOut(400);
$("#create-appointment-panel").fadeOut(400);
$("#add-medication-panel").fadeOut(400);
$("#assign-medication-panel").fadeOut(400);
$("#patient-graph").fadeOut(400);
$("#welcome-jumbo").slideUp(400).delay(400).fadeIn(400);
$("#results").html(xmlhttp.responseText).fadeIn(800).removeClass('hidden');
// add onclick listeners to links
$('patient-id').click(function(e) {
viewPatientProfile(e);
});
}
};
var doc_id = $("#doctor_id").html();
xmlhttp.open("POST","viewpatientlist.php",true);
// HTTP header required for POST
xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
xmlhttp.send("doctor_id=" + doc_id);
}
// Add Medication Submit Function
function addMedicationAJAX() {
var xmlhttp;
if (window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();
}
xmlhttp.onreadystatechange = function () {
$("#progdiv").fadeIn(400).removeClass('hidden');
if (xmlhttp.readyState == 1) {
$("#progbar").css("width", "25%");
} else if (xmlhttp.readyState == 2) {
$("#progbar").css("width", "50%");
} else if (xmlhttp.readyState == 3) {
$("#progbar").css("width", "75%");
}
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
$("#progbar").css("width", "100%");
setTimeout(function() {
$("#progdiv").fadeOut(800).delay(400).addClass('hidden');
}, 1000);
// clear out the form and present the result
$("#welcome-container").fadeOut(400);
$("#add-medication-panel").fadeOut(400);
$("#patient-graph").fadeOut(400);
$("#welcome-jumbo").slideUp(400).delay(400).fadeIn(400);
$("#results").html(xmlhttp.responseText).fadeIn(800).removeClass('hidden');
}
};
var doc_id = $("#doctor_id").html();
var medication_name = $("#medication_name").val();
var medication_type = $("#medication_type").val();
var intake_method = $("#intake_method").val();
var max_dosage = $("#max_dosage").val();
var min_dosage = $("#min_dosage").val();
xmlhttp.open("POST","add_medication.php",true);
// HTTP header required for POST
xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
xmlhttp.send("doctor_id=" + doc_id + "&medication_name=" + medication_name + "&medication_type=" + medication_type +
"&intake_method=" + intake_method + "&max_dosage=" + max_dosage + "&min_dosage=" + min_dosage);
}
// Assign Medication to Patient Submit Function
function assignMedicationAJAX() {
var xmlhttp;
if (window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();
}
xmlhttp.onreadystatechange = function () {
$("#progdiv").fadeIn(400).removeClass('hidden');
if (xmlhttp.readyState == 1) {
$("#progbar").css("width", "25%");
} else if (xmlhttp.readyState == 2) {
$("#progbar").css("width", "50%");
} else if (xmlhttp.readyState == 3) {
$("#progbar").css("width", "75%");
}
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
$("#progbar").css("width", "100%");
setTimeout(function() {
$("#progdiv").fadeOut(800).delay(400).addClass('hidden');
}, 1000);
// clear out the form and present the result
$("#welcome-container").fadeOut(400);
$("#assign-medication-panel").fadeOut(400);
$("#patient-graph").fadeOut(400);
$("#welcome-jumbo").slideUp(400).delay(400).fadeIn(400);
$("#results").html(xmlhttp.responseText).fadeIn(800).removeClass('hidden');
}
};
var doc_id = $("#doctor_id").html();
var medication_name = $("#assign_medication_name").val();
var patient_username = $("#assign_medication_patient").val();
var patient_name = $("#assign_medication_patient_name").val();
var dosage = $("#assign_medication_dosage").val();
var frequency = $("#assign_medication_frequency").val();
xmlhttp.open("POST","assign_medication.php",true);
// HTTP header required for POST
xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
xmlhttp.send("doctor_id=" + doc_id + "&medication_name=" + medication_name + "&patient_username=" + patient_username +
"&patient_name=" + patient_name + "&dosage=" + dosage + "&frequency=" + frequency);
}
// Display A list of Available Medications
function viewMedicationsAJAX() {
var xmlhttp;
if (window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();
}
xmlhttp.onreadystatechange = function () {
$("#progdiv").fadeIn(400).removeClass('hidden');
if (xmlhttp.readyState == 1) {
$("#progbar").css("width", "25%");
} else if (xmlhttp.readyState == 2) {
$("#progbar").css("width", "50%");
} else if (xmlhttp.readyState == 3) {
$("#progbar").css("width", "75%");
}
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
$("#progbar").css("width", "100%");
setTimeout(function() {
$("#progdiv").fadeOut(800).delay(400).addClass('hidden');
}, 1000);
// clear out the form and present the result
$("#welcome-container").fadeOut(400);
$("#add-patient-panel").fadeOut(400);
$("#create-appointment-panel").fadeOut(400);
$("#add-medication-panel").fadeOut(400);
$("#patient-graph").fadeOut(400);
$("#welcome-jumbo").slideUp(400).delay(400).fadeIn(400);
$("#results").html(xmlhttp.responseText).fadeIn(800).removeClass('hidden');
}
};
var doc_id = $("#doctor_id").html();
xmlhttp.open("POST","view_medication_list.php",true);
// HTTP header required for POST
xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
xmlhttp.send("doctor_id=" + doc_id);
}
function displayData() {
$("#welcome-container").fadeOut(400);
$("#add-patient-panel").fadeOut(400);
$("#create-appointment-panel").fadeOut(400);
$("#add-medication-panel").fadeOut(400);
$("#assign-medication-panel").fadeOut(400);
$("#results").fadeOut(400);
$("#welcome-jumbo").slideUp(400).delay(400).fadeIn(400);
$("#patient-graph").fadeIn(400).removeClass('hidden');
var data = {
labels: ["January", "February", "March", "April", "May", "June", "July"],
datasets: [
{
label: "My First dataset",
fillColor: "rgba(220,220,220,0.2)",
strokeColor: "rgba(220,220,220,1)",
pointColor: "rgba(220,220,220,1)",
pointStrokeColor: "#fff",
pointHighlightFill: "#fff",
pointHighlightStroke: "rgba(220,220,220,1)",
data: [6500, 5900, 8000, 8100, 5600, 5500, 4000]
},
{
label: "My Second dataset",
fillColor: "rgba(151,187,205,0.2)",
strokeColor: "rgba(151,187,205,1)",
pointColor: "rgba(151,187,205,1)",
pointStrokeColor: "#fff",
pointHighlightFill: "#fff",
pointHighlightStroke: "rgba(151,187,205,1)",
data: [2800, 4800, 4000, 1900, 8600, 2700, 9000]
}
]
};
// Get context with jQuery - using jQuery's .get() method.
var ctx = $("#myChart").get(0).getContext("2d");
// This will get the first returned node in the jQuery collection.
new Chart(ctx).Line(data);
}
$(document).ready(function(){
$("#data").click(function() {displayData();});
// activate all popovers
$(function () {
$('[data-toggle="popover"]').popover();
});
// show the welcome screen
$("#welcome-jumbo").fadeIn(800).removeClass('hidden');
// animate the jumbo to close and re-open with appropriate contents
// when clicking on the add patient link
$("#add-patient").click(function(){
$('#add-patient-form').show();
$("#create-appointment-form").hide();
$("#create-appointment-panel").hide();
$("#add-medication-form").hide();
$("#add-medication-panel").hide();
$("#assign-medication-form").hide();
$("#assign-medication-panel").hide();
$("#welcome-container").fadeOut(400);
$("#patient-graph").fadeOut(400);
$("#welcome-jumbo").slideUp(200).delay(400).fadeIn(400);
$("#results").fadeOut(400).delay(1000).addClass('hidden').empty();
// reset the form and errors