forked from openemr/openemr
/
demographics.php
1852 lines (1689 loc) · 73.8 KB
/
demographics.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
<?php
/**
*
* Patient summary screen.
*
* @package OpenEMR
* @link http://www.open-emr.org
* @author Brady Miller <brady.g.miller@gmail.com>
* @author Sharon Cohen <sharonco@matrix.co.il>
* @copyright Copyright (c) 2017 Brady Miller <brady.g.miller@gmail.com>
* @copyright Copyright (c) 2017 Sharon Cohen <sharonco@matrix.co.il>
* @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
*/
require_once("../../globals.php");
require_once("$srcdir/patient.inc");
require_once("$srcdir/acl.inc");
require_once("$srcdir/options.inc.php");
require_once("../history/history.inc.php");
require_once("$srcdir/edi.inc");
require_once("$srcdir/invoice_summary.inc.php");
require_once("$srcdir/clinical_rules.php");
require_once("$srcdir/options.js.php");
require_once("$srcdir/group.inc");
require_once(dirname(__FILE__)."/../../../library/appointments.inc.php");
use OpenEMR\Reminder\BirthdayReminder;
if (isset($_GET['set_pid'])) {
include_once("$srcdir/pid.inc");
setpid($_GET['set_pid']);
}
$active_reminders = false;
$all_allergy_alerts = false;
if ($GLOBALS['enable_cdr']) {
//CDR Engine stuff
if ($GLOBALS['enable_allergy_check'] && $GLOBALS['enable_alert_log']) {
//Check for new allergies conflicts and throw popup if any exist(note need alert logging to support this)
$new_allergy_alerts = allergy_conflict($pid, 'new', $_SESSION['authUser']);
if (!empty($new_allergy_alerts)) {
$pop_warning = '<script type="text/javascript">alert(\'' . xls('WARNING - FOLLOWING ACTIVE MEDICATIONS ARE ALLERGIES') . ':\n';
foreach ($new_allergy_alerts as $new_allergy_alert) {
$pop_warning .= addslashes($new_allergy_alert) . '\n';
}
$pop_warning .= '\')</script>';
echo $pop_warning;
}
}
if ((!isset($_SESSION['alert_notify_pid']) || ($_SESSION['alert_notify_pid'] != $pid)) && isset($_GET['set_pid']) && $GLOBALS['enable_cdr_crp']) {
// showing a new patient, so check for active reminders and allergy conflicts, which use in active reminder popup
$active_reminders = active_alert_summary($pid, "reminders-due", '', 'default', $_SESSION['authUser'], true);
if ($GLOBALS['enable_allergy_check']) {
$all_allergy_alerts = allergy_conflict($pid, 'all', $_SESSION['authUser'], true);
}
}
}
function print_as_money($money)
{
preg_match("/(\d*)\.?(\d*)/", $money, $moneymatches);
$tmp = wordwrap(strrev($moneymatches[1]), 3, ",", 1);
$ccheck = strrev($tmp);
if ($ccheck[0] == ",") {
$tmp = substr($ccheck, 1, strlen($ccheck)-1);
}
if ($moneymatches[2] != "") {
return "$ " . strrev($tmp) . "." . $moneymatches[2];
} else {
return "$ " . strrev($tmp);
}
}
// get an array from Photos category
function pic_array($pid, $picture_directory)
{
$pics = array();
$sql_query = "select documents.id from documents join categories_to_documents " .
"on documents.id = categories_to_documents.document_id " .
"join categories on categories.id = categories_to_documents.category_id " .
"where categories.name like ? and documents.foreign_id = ?";
if ($query = sqlStatement($sql_query, array($picture_directory,$pid))) {
while ($results = sqlFetchArray($query)) {
array_push($pics, $results['id']);
}
}
return ($pics);
}
// Get the document ID of the first document in a specific catg.
function get_document_by_catg($pid, $doc_catg)
{
$result = array();
if ($pid and $doc_catg) {
$result = sqlQuery("SELECT d.id, d.date, d.url FROM " .
"documents AS d, categories_to_documents AS cd, categories AS c " .
"WHERE d.foreign_id = ? " .
"AND cd.document_id = d.id " .
"AND c.id = cd.category_id " .
"AND c.name LIKE ? " .
"ORDER BY d.date DESC LIMIT 1", array($pid, $doc_catg));
}
return($result['id']);
}
// Display image in 'widget style'
function image_widget($doc_id, $doc_catg)
{
global $pid, $web_root;
$docobj = new Document($doc_id);
$image_file = $docobj->get_url_file();
$image_width = $GLOBALS['generate_doc_thumb'] == 1 ? '' : 'width=100';
$extension = substr($image_file, strrpos($image_file, "."));
$viewable_types = array('.png','.jpg','.jpeg','.png','.bmp','.PNG','.JPG','.JPEG','.PNG','.BMP'); // image ext supported by fancybox viewer
if (in_array($extension, $viewable_types)) { // extention matches list
$to_url = "<td> <a href = $web_root" .
"/controller.php?document&retrieve&patient_id=$pid&document_id=$doc_id&as_file=false&original_file=true&disable_exit=false&show_original=true" .
"/tmp$extension" . // Force image type URL for fancybo
" onclick=top.restoreSession(); class='image_modal'>" .
" <img src = $web_root" .
"/controller.php?document&retrieve&patient_id=$pid&document_id=$doc_id&as_file=false" .
" $image_width alt='$doc_catg:$image_file'> </a> </td> <td valign='center'>".
htmlspecialchars($doc_catg) . '<br /> ' . htmlspecialchars($image_file) .
"</td>";
} else {
$to_url = "<td> <a href='" . $web_root . "/controller.php?document&retrieve" .
"&patient_id=$pid&document_id=$doc_id'" .
" onclick='top.restoreSession()' class='css_button_small'>" .
"<span>" .
htmlspecialchars(xl("View"), ENT_QUOTES)."</a> " .
htmlspecialchars("$doc_catg - $image_file", ENT_QUOTES) .
"</span> </td>";
}
echo "<table><tr>";
echo $to_url;
echo "</tr></table>";
}
// Determine if the Vitals form is in use for this site.
$tmp = sqlQuery("SELECT count(*) AS count FROM registry WHERE " .
"directory = 'vitals' AND state = 1");
$vitals_is_registered = $tmp['count'];
// Get patient/employer/insurance information.
//
$result = getPatientData($pid, "*, DATE_FORMAT(DOB,'%Y-%m-%d') as DOB_YMD");
$result2 = getEmployerData($pid);
$result3 = getInsuranceData($pid, "primary", "copay, provider, DATE_FORMAT(`date`,'%Y-%m-%d') as effdate");
$insco_name = "";
if ($result3['provider']) { // Use provider in case there is an ins record w/ unassigned insco
$insco_name = getInsuranceProvider($result3['provider']);
}
?>
<html>
<head>
<?php html_header_show();?>
<link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
<link rel="stylesheet" type="text/css" href="../../../library/js/fancybox/jquery.fancybox-1.2.6.css" media="screen" />
<script type="text/javascript" src="../../../library/textformat.js?v=<?php echo $v_js_includes; ?>"></script>
<script type="text/javascript" src="../../../library/dialog.js?v=<?php echo $v_js_includes; ?>"></script>
<script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-7-2/index.js"></script>
<script type="text/javascript" src="../../../library/js/common.js?v=<?php echo $v_js_includes; ?>"></script>
<script type="text/javascript" src="../../../library/js/fancybox/jquery.fancybox-1.2.6.js"></script>
<script type="text/javascript" language="JavaScript">
var mypcc = '<?php echo htmlspecialchars($GLOBALS['phone_country_code'], ENT_QUOTES); ?>';
//////////
function oldEvt(apptdate, eventid) {
dlgopen('../../main/calendar/add_edit_event.php?date=' + apptdate + '&eid=' + eventid, '_blank', 775, 500);
}
function advdirconfigure() {
dlgopen('advancedirectives.php', '_blank', 400, 500);
}
function refreshme() {
top.restoreSession();
location.reload();
}
// Process click on Delete link.
function deleteme() {
dlgopen('../deleter.php?patient=<?php echo htmlspecialchars($pid, ENT_QUOTES); ?>', '_blank', 500, 450);
return false;
}
// Called by the deleteme.php window on a successful delete.
function imdeleted() {
<?php if ($GLOBALS['new_tabs_layout']) { ?>
top.clearPatient();
<?php } else { ?>
parent.left_nav.clearPatient();
<?php } ?>
}
function newEvt() {
dlgopen('../../main/calendar/add_edit_event.php?patientid=<?php echo htmlspecialchars($pid, ENT_QUOTES); ?>', '_blank', 775, 500);
return false;
}
function sendimage(pid, what) {
// alert('Not yet implemented.'); return false;
dlgopen('../upload_dialog.php?patientid=' + pid + '&file=' + what,
'_blank', 500, 400);
return false;
}
</script>
<script type="text/javascript">
function toggleIndicator(target,div) {
$mode = $(target).find(".indicator").text();
if ( $mode == "<?php echo htmlspecialchars(xl('collapse'), ENT_QUOTES); ?>" ) {
$(target).find(".indicator").text( "<?php echo htmlspecialchars(xl('expand'), ENT_QUOTES); ?>" );
$("#"+div).hide();
$.post( "../../../library/ajax/user_settings.php", { target: div, mode: 0 });
} else {
$(target).find(".indicator").text( "<?php echo htmlspecialchars(xl('collapse'), ENT_QUOTES); ?>" );
$("#"+div).show();
$.post( "../../../library/ajax/user_settings.php", { target: div, mode: 1 });
}
}
$(document).ready(function(){
var msg_updation='';
<?php
if ($GLOBALS['erx_enable']) {
//$soap_status=sqlQuery("select soap_import_status from patient_data where pid=?",array($pid));
$soap_status=sqlStatement("select soap_import_status,pid from patient_data where pid=? and soap_import_status in ('1','3')", array($pid));
while ($row_soapstatus=sqlFetchArray($soap_status)) {
//if($soap_status['soap_import_status']=='1' || $soap_status['soap_import_status']=='3'){ ?>
top.restoreSession();
$.ajax({
type: "POST",
url: "../../soap_functions/soap_patientfullmedication.php",
dataType: "html",
data: {
patient:<?php echo $row_soapstatus['pid']; ?>,
},
async: false,
success: function(thedata){
//alert(thedata);
msg_updation+=thedata;
},
error:function(){
alert('ajax error');
}
});
<?php
//}
//elseif($soap_status['soap_import_status']=='3'){ ?>
top.restoreSession();
$.ajax({
type: "POST",
url: "../../soap_functions/soap_allergy.php",
dataType: "html",
data: {
patient:<?php echo $row_soapstatus['pid']; ?>,
},
async: false,
success: function(thedata){
//alert(thedata);
msg_updation+=thedata;
},
error:function(){
alert('ajax error');
}
});
<?php
if ($GLOBALS['erx_import_status_message']) { ?>
if(msg_updation)
alert(msg_updation);
<?php
}
//}
}
}
?>
// load divs
$("#stats_div").load("stats.php", { 'embeddedScreen' : true }, function() {
// (note need to place javascript code here also to get the dynamic link to work)
$(".rx_modal").fancybox( {
'overlayOpacity' : 0.0,
'showCloseButton' : true,
'frameHeight' : 600,
'frameWidth' : 1200,
'centerOnScroll' : false,
'callbackOnClose' : function() {
refreshme();
}
});
});
$("#pnotes_ps_expand").load("pnotes_fragment.php");
$("#disclosures_ps_expand").load("disc_fragment.php");
<?php if ($GLOBALS['enable_cdr'] && $GLOBALS['enable_cdr_crw']) { ?>
top.restoreSession();
$("#clinical_reminders_ps_expand").load("clinical_reminders_fragment.php", { 'embeddedScreen' : true }, function() {
// (note need to place javascript code here also to get the dynamic link to work)
$(".medium_modal").fancybox( {
'overlayOpacity' : 0.0,
'showCloseButton' : true,
'frameHeight' : 500,
'frameWidth' : 800,
'centerOnScroll' : false,
'callbackOnClose' : function() {
refreshme();
}
});
});
<?php } // end crw?>
<?php if ($GLOBALS['enable_cdr'] && $GLOBALS['enable_cdr_prw']) { ?>
top.restoreSession();
$("#patient_reminders_ps_expand").load("patient_reminders_fragment.php");
<?php } // end prw?>
<?php if ($vitals_is_registered && acl_check('patients', 'med')) { ?>
// Initialize the Vitals form if it is registered and user is authorized.
$("#vitals_ps_expand").load("vitals_fragment.php");
<?php } ?>
// Initialize track_anything
$("#track_anything_ps_expand").load("track_anything_fragment.php");
// Initialize labdata
$("#labdata_ps_expand").load("labdata_fragment.php");
<?php
// Initialize for each applicable LBF form.
$gfres = sqlStatement("SELECT option_id FROM list_options WHERE " .
"list_id = 'lbfnames' AND option_value > 0 AND activity = 1 ORDER BY seq, title");
while ($gfrow = sqlFetchArray($gfres)) { ?>
$("#<?php echo $gfrow['option_id']; ?>_ps_expand").load("lbf_fragment.php?formname=<?php echo $gfrow['option_id']; ?>");<?php
}
?>
// fancy box
enable_modals();
tabbify();
// modal for dialog boxes
$(".large_modal").fancybox( {
'overlayOpacity' : 0.0,
'showCloseButton' : true,
'frameHeight' : 600,
'frameWidth' : 1000,
'centerOnScroll' : false
});
// modal for image viewer
$(".image_modal").fancybox( {
'overlayOpacity' : 0.0,
'showCloseButton' : true,
'centerOnScroll' : false,
'autoscale' : true
});
$(".iframe1").fancybox( {
'left':10,
'overlayOpacity' : 0.0,
'showCloseButton' : true,
'frameHeight' : 300,
'frameWidth' : 350
});
// special size for patient portal
$(".small_modal").fancybox( {
'overlayOpacity' : 0.0,
'showCloseButton' : true,
'frameHeight' : 200,
'frameWidth' : 380,
'centerOnScroll' : false
});
<?php if ($active_reminders || $all_allergy_alerts) { ?>
// show the active reminder modal
$("#reminder_popup_link").fancybox({
'overlayOpacity' : 0.0,
'showCloseButton' : true,
'frameHeight' : 500,
'frameWidth' : 500,
'centerOnScroll' : false
}).trigger('click');
<?php } ?>
<?php if ($GLOBALS['patient_birthday_alert']) {
// To display the birthday alert:
// 1. The patient is not deceased
// 2. The birthday is today (or in the past depending on global selection)
// 3. The notification has not been turned off (or shown depending on global selection) for this year
$birthdayAlert = new BirthdayReminder($pid, $_SESSION['authId']);
if ($birthdayAlert->isDisplayBirthdayAlert()) {
?>
// show the active reminder modal
$("#birthday_popup").fancybox({
'overlayOpacity' : 0.0,
'showCloseButton' : true,
'frameHeight' : 170,
'frameWidth' : 200,
'centerOnScroll' : false
}).trigger('click');
<?php } ?>
<?php } ?>
});
// JavaScript stuff to do when a new patient is set.
//
function setMyPatient() {
// Avoid race conditions with loading of the left_nav or Title frame.
if (!parent.allFramesLoaded()) {
setTimeout("setMyPatient()", 500);
return;
}
<?php if (isset($_GET['set_pid'])) { ?>
parent.left_nav.setPatient(<?php echo "'" . addslashes($result['fname']) . " " . addslashes($result['lname']) .
"'," . addslashes($pid) . ",'" . addslashes($result['pubpid']) .
"','', ' " . xls('DOB') . ": " . addslashes(oeFormatShortDate($result['DOB_YMD'])) . " " . xls('Age') . ": " . addslashes(getPatientAgeDisplay($result['DOB_YMD'])) . "'"; ?>);
var EncounterDateArray = new Array;
var CalendarCategoryArray = new Array;
var EncounterIdArray = new Array;
var Count = 0;
<?php
//Encounter details are stored to javacript as array.
$result4 = sqlStatement("SELECT fe.encounter,fe.date,openemr_postcalendar_categories.pc_catname FROM form_encounter AS fe ".
" left join openemr_postcalendar_categories on fe.pc_catid=openemr_postcalendar_categories.pc_catid WHERE fe.pid = ? order by fe.date desc", array($pid));
if (sqlNumRows($result4)>0) {
while ($rowresult4 = sqlFetchArray($result4)) {
?>
EncounterIdArray[Count] = '<?php echo addslashes($rowresult4['encounter']); ?>';
EncounterDateArray[Count] = '<?php echo addslashes(oeFormatShortDate(date("Y-m-d", strtotime($rowresult4['date'])))); ?>';
CalendarCategoryArray[Count] = '<?php echo addslashes(xl_appt_category($rowresult4['pc_catname'])); ?>';
Count++;
<?php
}
}
?>
parent.left_nav.setPatientEncounter(EncounterIdArray,EncounterDateArray,CalendarCategoryArray);
<?php } // end setting new pid ?>
parent.left_nav.syncRadios();
<?php if ((isset($_GET['set_pid']) ) && (isset($_GET['set_encounterid'])) && ( intval($_GET['set_encounterid']) > 0 )) {
$encounter = intval($_GET['set_encounterid']);
$_SESSION['encounter'] = $encounter;
$query_result = sqlQuery("SELECT `date` FROM `form_encounter` WHERE `encounter` = ?", array($encounter)); ?>
encurl = 'encounter/encounter_top.php?set_encounter=' + <?php echo attr($encounter);?> + '&pid=' + <?php echo attr($pid);?>;
<?php if ($GLOBALS['new_tabs_layout']) { ?>
parent.left_nav.setEncounter('<?php echo oeFormatShortDate(date("Y-m-d", strtotime($query_result['date']))); ?>', '<?php echo attr($encounter); ?>', 'enc');
top.restoreSession();
parent.left_nav.loadFrame('enc2', 'enc', 'patient_file/' + encurl);
<?php } else { ?>
var othername = (window.name == 'RTop') ? 'RBot' : 'RTop';
parent.left_nav.setEncounter('<?php echo oeFormatShortDate(date("Y-m-d", strtotime($query_result['date']))); ?>', '<?php echo attr($encounter); ?>', othername);
top.restoreSession();
parent.frames[othername].location.href = '../' + encurl;
<?php } ?>
<?php } // end setting new encounter id (only if new pid is also set) ?>
}
$(window).load(function() {
setMyPatient();
});
</script>
<style type="css/text">
#pnotes_ps_expand {
height:auto;
width:100%;
}
</style>
</head>
<body class="body_top patient-demographics">
<a href='../reminder/active_reminder_popup.php' id='reminder_popup_link' style='display: none;' class='iframe' onclick='top.restoreSession()'></a>
<a href='../birthday_alert/birthday_pop.php?pid=<?php echo attr($pid); ?>&user_id=<?php echo attr($_SESSION['authId']); ?>' id='birthday_popup' style='display: none;' class='iframe' onclick='top.restoreSession()'></a>
<?php
$thisauth = acl_check('patients', 'demo');
if ($thisauth) {
if ($result['squad'] && ! acl_check('squads', $result['squad'])) {
$thisauth = 0;
}
}
if (!$thisauth) {
echo "<p>(" . htmlspecialchars(xl('Demographics not authorized'), ENT_NOQUOTES) . ")</p>\n";
echo "</body>\n</html>\n";
exit();
}
if ($thisauth) : ?>
<table class="table_header">
<tr>
<td>
<span class='title'>
<?php echo htmlspecialchars(getPatientName($pid), ENT_NOQUOTES); ?>
</span>
</td>
<?php if (acl_check('admin', 'super') && $GLOBALS['allow_pat_delete']) : ?>
<td style='padding-left:1em;' class="delete">
<a class='css_button iframe'
href='../deleter.php?patient=<?php echo htmlspecialchars($pid, ENT_QUOTES);?>'
onclick='top.restoreSession()'>
<span><?php echo htmlspecialchars(xl('Delete'), ENT_NOQUOTES);?></span>
</a>
</td>
<?php endif; // Allow PT delete
if ($GLOBALS['erx_enable']) : ?>
<td style="padding-left:1em;" class="erx">
<a class="css_button" href="../../eRx.php?page=medentry" onclick="top.restoreSession()">
<span><?php echo htmlspecialchars(xl('NewCrop MedEntry'), ENT_NOQUOTES);?></span>
</a>
</td>
<td style="padding-left:1em;">
<a class="css_button iframe1"
href="../../soap_functions/soap_accountStatusDetails.php"
onclick="top.restoreSession()">
<span><?php echo htmlspecialchars(xl('NewCrop Account Status'), ENT_NOQUOTES);?></span>
</a>
</td>
<td id='accountstatus'></td>
<?php endif; // eRX Enabled
//Patient Portal
$portalUserSetting = true; //flag to see if patient has authorized access to portal
if (($GLOBALS['portal_onsite_enable'] && $GLOBALS['portal_onsite_address']) ||
($GLOBALS['portal_onsite_two_enable'] && $GLOBALS['portal_onsite_two_address']) ) :
$portalStatus = sqlQuery("SELECT allow_patient_portal FROM patient_data WHERE pid=?", array($pid));
if ($portalStatus['allow_patient_portal']=='YES') :
$portalLogin = sqlQuery("SELECT pid FROM `patient_access_onsite` WHERE `pid`=?", array($pid));?>
<td style='padding-left:1em;'>
<a class='css_button iframe small_modal'
href='create_portallogin.php?portalsite=on&patient=<?php echo htmlspecialchars($pid, ENT_QUOTES);?>'
onclick='top.restoreSession()'>
<?php $display = (empty($portalLogin)) ? xlt('Create Onsite Portal Credentials') : xlt('Reset Onsite Portal Credentials'); ?>
<span><?php echo $display; ?></span>
</a>
</td>
<?php
else :
$portalUserSetting = false;
endif; // allow patient portal
endif; // Onsite Patient Portal
if ($GLOBALS['portal_offsite_enable'] && $GLOBALS['portal_offsite_address']) :
$portalStatus = sqlQuery("SELECT allow_patient_portal FROM patient_data WHERE pid=?", array($pid));
if ($portalStatus['allow_patient_portal']=='YES') :
$portalLogin = sqlQuery("SELECT pid FROM `patient_access_offsite` WHERE `pid`=?", array($pid));
?>
<td style='padding-left:1em;'>
<a class='css_button iframe small_modal'
href='create_portallogin.php?portalsite=off&patient=<?php echo htmlspecialchars($pid, ENT_QUOTES);?>'
onclick='top.restoreSession()'>
<span>
<?php $text = (empty($portalLogin)) ? xlt('Create Offsite Portal Credentials') : xlt('Reset Offsite Portal Credentials'); ?>
<?php echo $text; ?>
</span>
</a>
</td>
<?php
else :
$portalUserSetting = false;
endif; // allow_patient_portal
endif; // portal_offsite_enable
if (!($portalUserSetting)) : // Show that the patient has not authorized portal access ?>
<td style='padding-left:1em;'>
<?php echo htmlspecialchars(xl('Patient has not authorized the Patient Portal.'), ENT_NOQUOTES);?>
</td>
<?php endif;
//Patient Portal
// If patient is deceased, then show this (along with the number of days patient has been deceased for)
$days_deceased = is_patient_deceased($pid);
if ($days_deceased != null) : ?>
<td class="deceased" style="padding-left:1em;font-weight:bold;color:red">
<?php
if ($days_deceased == 0) {
echo xlt("DECEASED (Today)");
} else if ($days_deceased == 1) {
echo xlt("DECEASED (1 day ago)");
} else {
echo xlt("DECEASED") . " (" . text($days_deceased) . " " . xlt("days ago") . ")";
} ?>
</td>
<?php endif; ?>
</tr>
</table>
<?php
endif; // $thisauth
?>
<?php
// Get the document ID of the patient ID card if access to it is wanted here.
$idcard_doc_id = false;
if ($GLOBALS['patient_id_category_name']) {
$idcard_doc_id = get_document_by_catg($pid, $GLOBALS['patient_id_category_name']);
}
?>
<table cellspacing='0' cellpadding='0' border='0' class="subnav">
<tr>
<td class="small" colspan='4'>
<a href="../history/history.php" onclick='top.restoreSession()'>
<?php echo htmlspecialchars(xl('History'), ENT_NOQUOTES); ?></a>
|
<?php //note that we have temporarily removed report screen from the modal view ?>
<a href="../report/patient_report.php" onclick='top.restoreSession()'>
<?php echo htmlspecialchars(xl('Report'), ENT_NOQUOTES); ?></a>
|
<?php //note that we have temporarily removed document screen from the modal view ?>
<a href="../../../controller.php?document&list&patient_id=<?php echo $pid;?>" onclick='top.restoreSession()'>
<?php echo htmlspecialchars(xl('Documents'), ENT_NOQUOTES); ?></a>
|
<a href="../transaction/transactions.php" onclick='top.restoreSession()'>
<?php echo htmlspecialchars(xl('Transactions'), ENT_NOQUOTES); ?></a>
|
<a href="stats_full.php?active=all" onclick='top.restoreSession()'>
<?php echo htmlspecialchars(xl('Issues'), ENT_NOQUOTES); ?></a>
|
<a href="../../reports/pat_ledger.php?form=1&patient_id=<?php echo attr($pid);?>" onclick='top.restoreSession()'>
<?php echo xlt('Ledger'); ?></a>
|
<a href="../../reports/external_data.php" onclick='top.restoreSession()'>
<?php echo xlt('External Data'); ?></a>
<!-- DISPLAYING HOOKS STARTS HERE -->
<?php
$module_query = sqlStatement("SELECT msh.*,ms.obj_name,ms.menu_name,ms.path,m.mod_ui_name,m.type FROM modules_hooks_settings AS msh
LEFT OUTER JOIN modules_settings AS ms ON obj_name=enabled_hooks AND ms.mod_id=msh.mod_id
LEFT OUTER JOIN modules AS m ON m.mod_id=ms.mod_id
WHERE fld_type=3 AND mod_active=1 AND sql_run=1 AND attached_to='demographics' ORDER BY mod_id");
$DivId = 'mod_installer';
if (sqlNumRows($module_query)) {
$jid = 0;
$modid = '';
while ($modulerow = sqlFetchArray($module_query)) {
$DivId = 'mod_'.$modulerow['mod_id'];
$new_category = $modulerow['mod_ui_name'];
$modulePath = "";
$added = "";
if ($modulerow['type'] == 0) {
$modulePath = $GLOBALS['customModDir'];
$added = "";
} else {
$added = "index";
$modulePath = $GLOBALS['zendModDir'];
}
if (!acl_check('admin', 'super') && !zh_acl_check($_SESSION['authUserID'], $modulerow['obj_name'])) {
continue;
}
$relative_link = "../../modules/".$modulePath."/".$modulerow['path'];
$nickname = $modulerow['menu_name'] ? $modulerow['menu_name'] : 'Noname';
$jid++;
$modid = $modulerow['mod_id'];
?>
|
<a href="<?php echo $relative_link; ?>" onclick='top.restoreSession()'>
<?php echo xlt($nickname); ?></a>
<?php
}
}
?>
<!-- DISPLAYING HOOKS ENDS HERE -->
</td>
</tr>
</table> <!-- end header -->
<div style='margin-top:10px' class="main"> <!-- start main content div -->
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>
<td class="demographics-box" align="left" valign="top">
<!-- start left column div -->
<div style='float:left; margin-right:20px'>
<table cellspacing=0 cellpadding=0>
<?php if (!$GLOBALS['hide_billing_widget']) { ?>
<tr>
<td>
<?php
// Billing expand collapse widget
$widgetTitle = xl("Billing");
$widgetLabel = "billing";
$widgetButtonLabel = xl("Edit");
$widgetButtonLink = "return newEvt();";
$widgetButtonClass = "";
$linkMethod = "javascript";
$bodyClass = "notab";
$widgetAuth = false;
$fixedWidth = true;
if ($GLOBALS['force_billing_widget_open']) {
$forceExpandAlways = true;
} else {
$forceExpandAlways = false;
}
expand_collapse_widget(
$widgetTitle,
$widgetLabel,
$widgetButtonLabel,
$widgetButtonLink,
$widgetButtonClass,
$linkMethod,
$bodyClass,
$widgetAuth,
$fixedWidth,
$forceExpandAlways
);
?>
<br>
<?php
//PATIENT BALANCE,INS BALANCE naina@capminds.com
$patientbalance = get_patient_balance($pid, false);
//Debit the patient balance from insurance balance
$insurancebalance = get_patient_balance($pid, true) - $patientbalance;
$totalbalance=$patientbalance + $insurancebalance;
// Show current balance and billing note, if any.
echo "<table border='0'><tr><td>" .
"<table ><tr><td><span class='bold'><font color='red'>" .
xlt('Patient Balance Due') .
" : " . text(oeFormatMoney($patientbalance)) .
"</font></span></td></tr>".
"<tr><td><span class='bold'><font color='red'>" .
xlt('Insurance Balance Due') .
" : " . text(oeFormatMoney($insurancebalance)) .
"</font></span></td></tr>".
"<tr><td><span class='bold'><font color='red'>" .
xlt('Total Balance Due').
" : " . text(oeFormatMoney($totalbalance)) .
"</font></span></td></td></tr>";
if (!empty($result['billing_note'])) {
echo "<tr><td><span class='bold'><font color='red'>" .
xlt('Billing Note') . ":" .
text($result['billing_note']) .
"</font></span></td></tr>";
}
if ($result3['provider']) { // Use provider in case there is an ins record w/ unassigned insco
echo "<tr><td><span class='bold'>" .
xlt('Primary Insurance') . ': ' . text($insco_name) .
"</span> ";
if ($result3['copay'] > 0) {
echo "<span class='bold'>" .
xlt('Copay') . ': ' . text($result3['copay']) .
"</span> ";
}
echo "<span class='bold'>" .
xlt('Effective Date') . ': ' . text(oeFormatShortDate($result3['effdate'])) .
"</span></td></tr>";
}
echo "</table></td></tr></td></tr></table><br>";
?>
</div> <!-- required for expand_collapse_widget -->
</td>
</tr>
<?php } ?>
<?php if (acl_check('patients', 'demo')) { ?>
<tr>
<td>
<?php
// Demographics expand collapse widget
$widgetTitle = xl("Demographics");
$widgetLabel = "demographics";
$widgetButtonLabel = xl("Edit");
$widgetButtonLink = "demographics_full.php";
$widgetButtonClass = "";
$linkMethod = "html";
$bodyClass = "";
$widgetAuth = acl_check('patients', 'demo', '', 'write');
$fixedWidth = true;
expand_collapse_widget(
$widgetTitle,
$widgetLabel,
$widgetButtonLabel,
$widgetButtonLink,
$widgetButtonClass,
$linkMethod,
$bodyClass,
$widgetAuth,
$fixedWidth
);
?>
<div id="DEM" >
<ul class="tabNav">
<?php display_layout_tabs('DEM', $result, $result2); ?>
</ul>
<div class="tabContainer">
<?php display_layout_tabs_data('DEM', $result, $result2); ?>
</div>
</div>
</div> <!-- required for expand_collapse_widget -->
</td>
</tr>
<tr>
<td>
<?php
$insurance_count = 0;
foreach (array('primary','secondary','tertiary') as $instype) {
$enddate = 'Present';
$query = "SELECT * FROM insurance_data WHERE " .
"pid = ? AND type = ? " .
"ORDER BY date DESC";
$res = sqlStatement($query, array($pid, $instype));
while ($row = sqlFetchArray($res)) {
if ($row['provider']) {
$insurance_count++;
}
}
}
if ($insurance_count > 0) {
// Insurance expand collapse widget
$widgetTitle = xl("Insurance");
$widgetLabel = "insurance";
$widgetButtonLabel = xl("Edit");
$widgetButtonLink = "demographics_full.php";
$widgetButtonClass = "";
$linkMethod = "html";
$bodyClass = "";
$widgetAuth = acl_check('patients', 'demo', '', 'write');
$fixedWidth = true;
expand_collapse_widget(
$widgetTitle,
$widgetLabel,
$widgetButtonLabel,
$widgetButtonLink,
$widgetButtonClass,
$linkMethod,
$bodyClass,
$widgetAuth,
$fixedWidth
);
if ($insurance_count > 0) {
?>
<ul class="tabNav"><?php
///////////////////////////////// INSURANCE SECTION
$first = true;
foreach (array('primary','secondary','tertiary') as $instype) {
$query = "SELECT * FROM insurance_data WHERE " .
"pid = ? AND type = ? " .
"ORDER BY date DESC";
$res = sqlStatement($query, array($pid, $instype));
$enddate = 'Present';
while ($row = sqlFetchArray($res)) {
if ($row['provider']) {
$ins_description = ucfirst($instype);
$ins_description = xl($ins_description);
$ins_description .= strcmp($enddate, 'Present') != 0 ? " (".xl('Old').")" : "";
?>
<li <?php echo $first ? 'class="current"' : '' ?>><a href="#">
<?php echo htmlspecialchars($ins_description, ENT_NOQUOTES); ?></a></li>
<?php
$first = false;
}
$enddate = $row['date'];
}
}
// Display the eligibility tab
echo "<li><a href='#'>" .
htmlspecialchars(xl('Eligibility'), ENT_NOQUOTES) . "</a></li>";
?></ul><?php
} ?>
<div class="tabContainer">
<?php
$first = true;
foreach (array('primary','secondary','tertiary') as $instype) {
$enddate = 'Present';
$query = "SELECT * FROM insurance_data WHERE " .
"pid = ? AND type = ? " .
"ORDER BY date DESC";
$res = sqlStatement($query, array($pid, $instype));
while ($row = sqlFetchArray($res)) {
if ($row['provider']) {
?>
<div class="tab <?php echo $first ? 'current' : '' ?>">
<table border='0' cellpadding='0' width='100%'>
<?php
$icobj = new InsuranceCompany($row['provider']);
$adobj = $icobj->get_address();
$insco_name = trim($icobj->get_name());
?>
<tr>
<td valign='top' colspan='3'>
<span class='text'>
<?php
if (strcmp($enddate, 'Present') != 0) {
echo htmlspecialchars(xl("Old"), ENT_NOQUOTES)." ";
}
?>
<?php $tempinstype=ucfirst($instype);
echo htmlspecialchars(xl($tempinstype.' Insurance'), ENT_NOQUOTES); ?>
<?php if (strcmp($row['date'], '0000-00-00') != 0) { ?>
<?php echo htmlspecialchars(xl('from', '', ' ', ' ').$row['date'], ENT_NOQUOTES); ?>
<?php } ?>
<?php echo htmlspecialchars(xl('until', '', ' ', ' '), ENT_NOQUOTES);
echo (strcmp($enddate, 'Present') != 0) ? $enddate : htmlspecialchars(xl('Present'), ENT_NOQUOTES); ?>:</span>
</td>
</tr>
<tr>
<td valign='top'>
<span class='text'>
<?php
if ($insco_name) {
echo htmlspecialchars($insco_name, ENT_NOQUOTES) . '<br>';
if (trim($adobj->get_line1())) {
echo htmlspecialchars($adobj->get_line1(), ENT_NOQUOTES) . '<br>';
echo htmlspecialchars($adobj->get_city() . ', ' . $adobj->get_state() . ' ' . $adobj->get_zip(), ENT_NOQUOTES);
}
} else {
echo "<font color='red'><b>".htmlspecialchars(xl('Unassigned'), ENT_NOQUOTES)."</b></font>";
}
?>
<br>
<?php echo htmlspecialchars(xl('Policy Number'), ENT_NOQUOTES); ?>:
<?php echo htmlspecialchars($row['policy_number'], ENT_NOQUOTES) ?><br>
<?php echo htmlspecialchars(xl('Plan Name'), ENT_NOQUOTES); ?>:
<?php echo htmlspecialchars($row['plan_name'], ENT_NOQUOTES); ?><br>
<?php echo htmlspecialchars(xl('Group Number'), ENT_NOQUOTES); ?>:
<?php echo htmlspecialchars($row['group_number'], ENT_NOQUOTES); ?></span>
</td>
<td valign='top'>
<span class='bold'><?php echo htmlspecialchars(xl('Subscriber'), ENT_NOQUOTES); ?>: </span><br>
<span class='text'><?php echo htmlspecialchars($row['subscriber_fname'] . ' ' . $row['subscriber_mname'] . ' ' . $row['subscriber_lname'], ENT_NOQUOTES); ?>
<?php
if ($row['subscriber_relationship'] != "") {
echo "(" . htmlspecialchars($row['subscriber_relationship'], ENT_NOQUOTES) . ")";
}
?>
<br>
<?php echo htmlspecialchars(xl('S.S.'), ENT_NOQUOTES); ?>:
<?php echo htmlspecialchars($row['subscriber_ss'], ENT_NOQUOTES); ?><br>
<?php echo htmlspecialchars(xl('D.O.B.'), ENT_NOQUOTES); ?>:
<?php
if ($row['subscriber_DOB'] != "0000-00-00 00:00:00") {
echo htmlspecialchars($row['subscriber_DOB'], ENT_NOQUOTES);
}
?><br>
<?php echo htmlspecialchars(xl('Phone'), ENT_NOQUOTES); ?>:
<?php echo htmlspecialchars($row['subscriber_phone'], ENT_NOQUOTES); ?>
</span>
</td>
<td valign='top'>
<span class='bold'><?php echo htmlspecialchars(xl('Subscriber Address'), ENT_NOQUOTES); ?>: </span><br>
<span class='text'><?php echo htmlspecialchars($row['subscriber_street'], ENT_NOQUOTES); ?><br>
<?php echo htmlspecialchars($row['subscriber_city'], ENT_NOQUOTES); ?>
<?php
if ($row['subscriber_state'] != "") {
echo ", ";
}
echo htmlspecialchars($row['subscriber_state'], ENT_NOQUOTES); ?>
<?php
if ($row['subscriber_country'] != "") {
echo ", ";
}
echo htmlspecialchars($row['subscriber_country'], ENT_NOQUOTES); ?>
<?php echo " " . htmlspecialchars($row['subscriber_postal_code'], ENT_NOQUOTES); ?></span>
<?php if (trim($row['subscriber_employer'])) { ?>
<br><span class='bold'><?php echo htmlspecialchars(xl('Subscriber Employer'), ENT_NOQUOTES); ?>: </span><br>
<span class='text'><?php echo htmlspecialchars($row['subscriber_employer'], ENT_NOQUOTES); ?><br>
<?php echo htmlspecialchars($row['subscriber_employer_street'], ENT_NOQUOTES); ?><br>
<?php echo htmlspecialchars($row['subscriber_employer_city'], ENT_NOQUOTES); ?>
<?php
if ($row['subscriber_employer_city'] != "") {
echo ", ";
}