-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
/
forms.php
1087 lines (998 loc) · 39.1 KB
/
forms.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
/**
* forms.php
*
* @package OpenEMR
* @link http://www.open-emr.org
* @author Brady Miller <brady.g.miller@gmail.com>
* @copyright Copyright (c) 2018 Brady Miller <brady.g.miller@gmail.com>
* @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
*/
require_once("../../globals.php");
require_once("$srcdir/encounter.inc");
require_once("$srcdir/group.inc");
require_once("$srcdir/calendar.inc");
require_once("$srcdir/acl.inc");
require_once("$srcdir/patient.inc");
require_once("$srcdir/amc.php");
require_once $GLOBALS['srcdir'].'/ESign/Api.php';
require_once("$srcdir/../controllers/C_Document.class.php");
use ESign\Api;
use OpenEMR\Core\Header;
$reviewMode = false;
if (!empty($_REQUEST['review_id'])) {
$reviewMode = true;
$encounter=sanitizeNumber($_REQUEST['review_id']);
}
$is_group = ($attendant_type == 'gid') ? true : false;
if ($attendant_type == 'gid') {
$groupId = $therapy_group;
}
$attendant_id = $attendant_type == 'pid' ? $pid : $therapy_group;
if ($is_group && !acl_check("groups", "glog", false, array('view','write'))) {
echo xlt("access not allowed");
exit();
}
?>
<html>
<head>
<?php require $GLOBALS['srcdir'] . '/js/xl/dygraphs.js.php'; ?>
<?php Header::setupHeader(['common','esign','dygraphs']); ?>
<?php
$esignApi = new Api();
?>
<?php // if the track_anything form exists, then include the styling and js functions for graphing
if (file_exists(dirname(__FILE__) . "/../../forms/track_anything/style.css")) { ?>
<script type="text/javascript" src="<?php echo $GLOBALS['web_root']?>/interface/forms/track_anything/report.js"></script>
<link rel="stylesheet" href="<?php echo $GLOBALS['web_root']?>/interface/forms/track_anything/style.css" type="text/css">
<?php } ?>
<?php
// If the user requested attachment of any orphaned procedure orders, do it.
if (!empty($_GET['attachid'])) {
$attachid = explode(',', $_GET['attachid']);
foreach ($attachid as $aid) {
$aid = intval($aid);
if (!$aid) {
continue;
}
$tmp = sqlQuery(
"SELECT COUNT(*) AS count FROM procedure_order WHERE " .
"procedure_order_id = ? AND patient_id = ? AND encounter_id = 0 AND activity = 1",
array($aid, $pid)
);
if (!empty($tmp['count'])) {
sqlStatement(
"UPDATE procedure_order SET encounter_id = ? WHERE " .
"procedure_order_id = ? AND patient_id = ? AND encounter_id = 0 AND activity = 1",
array($encounter, $aid, $pid)
);
addForm($encounter, "Procedure Order", $aid, "procedure_order", $pid, $userauthorized);
}
}
}
?>
<script type="text/javascript">
$.noConflict();
jQuery(document).ready( function($) {
var formConfig = <?php echo $esignApi->formConfigToJson(); ?>;
$(".esign-button-form").esign(
formConfig,
{
afterFormSuccess : function( response ) {
if ( response.locked ) {
var editButtonId = "form-edit-button-"+response.formDir+"-"+response.formId;
$("#"+editButtonId).replaceWith( response.editButtonHtml );
}
var logId = "esign-signature-log-"+response.formDir+"-"+response.formId;
$.post( formConfig.logViewAction, response, function( html ) {
$("#"+logId).replaceWith( html );
});
}
}
);
var encounterConfig = <?php echo $esignApi->encounterConfigToJson(); ?>;
$(".esign-button-encounter").esign(
encounterConfig,
{
afterFormSuccess : function( response ) {
// If the response indicates a locked encounter, replace all
// form edit buttons with a "disabled" button, and "disable" left
// nav visit form links
if ( response.locked ) {
// Lock the form edit buttons
$(".form-edit-button").replaceWith( response.editButtonHtml );
// Disable the new-form capabilities in left nav
top.window.parent.left_nav.syncRadios();
// Disable the new-form capabilities in top nav of the encounter
$(".encounter-form-category-li").remove();
}
var logId = "esign-signature-log-encounter-"+response.encounterId;
$.post( encounterConfig.logViewAction, response, function( html ) {
$("#"+logId).replaceWith( html );
});
}
}
);
$("#prov_edu_res").click(function() {
if ( $('#prov_edu_res').prop('checked') ) {
var mode = "add";
}
else {
var mode = "remove";
}
top.restoreSession();
$.post( "../../../library/ajax/amc_misc_data.php",
{ amc_id: "patient_edu_amc",
complete: true,
mode: mode,
patient_id: <?php echo htmlspecialchars($pid, ENT_NOQUOTES); ?>,
object_category: "form_encounter",
object_id: <?php echo htmlspecialchars($encounter, ENT_NOQUOTES); ?>
}
);
});
$("#provide_sum_pat_flag").click(function() {
if ( $('#provide_sum_pat_flag').prop('checked') ) {
var mode = "add";
}
else {
var mode = "remove";
}
top.restoreSession();
$.post( "../../../library/ajax/amc_misc_data.php",
{ amc_id: "provide_sum_pat_amc",
complete: true,
mode: mode,
patient_id: <?php echo htmlspecialchars($pid, ENT_NOQUOTES); ?>,
object_category: "form_encounter",
object_id: <?php echo htmlspecialchars($encounter, ENT_NOQUOTES); ?>
}
);
});
$("#trans_trand_care").click(function() {
if ( $('#trans_trand_care').prop('checked') ) {
var mode = "add";
// Enable the reconciliation checkbox
$("#med_reconc_perf").removeAttr("disabled");
$("#soc_provided").removeAttr("disabled");
}
else {
var mode = "remove";
//Disable the reconciliation checkbox (also uncheck it if applicable)
$("#med_reconc_perf").attr("disabled", true);
$("#med_reconc_perf").prop("checked",false);
$("#soc_provided").attr("disabled",true);
$("#soc_provided").prop("checked",false);
}
top.restoreSession();
$.post( "../../../library/ajax/amc_misc_data.php",
{ amc_id: "med_reconc_amc",
complete: false,
mode: mode,
patient_id: <?php echo htmlspecialchars($pid, ENT_NOQUOTES); ?>,
object_category: "form_encounter",
object_id: <?php echo htmlspecialchars($encounter, ENT_NOQUOTES); ?>
}
);
});
$("#med_reconc_perf").click(function() {
if ( $('#med_reconc_perf').prop('checked') ) {
var mode = "complete";
}
else {
var mode = "uncomplete";
}
top.restoreSession();
$.post( "../../../library/ajax/amc_misc_data.php",
{ amc_id: "med_reconc_amc",
complete: true,
mode: mode,
patient_id: <?php echo htmlspecialchars($pid, ENT_NOQUOTES); ?>,
object_category: "form_encounter",
object_id: <?php echo htmlspecialchars($encounter, ENT_NOQUOTES); ?>
}
);
});
$("#soc_provided").click(function(){
if($('#soc_provided').prop('checked')){
var mode = "soc_provided";
}
else{
var mode = "no_soc_provided";
}
top.restoreSession();
$.post( "../../../library/ajax/amc_misc_data.php",
{ amc_id: "med_reconc_amc",
complete: true,
mode: mode,
patient_id: <?php echo htmlspecialchars($pid, ENT_NOQUOTES); ?>,
object_category: "form_encounter",
object_id: <?php echo htmlspecialchars($encounter, ENT_NOQUOTES); ?>
}
);
});
$(".deleteme").click(function(evt) { deleteme(); evt.stopPropogation(); });
<?php
// If the user was not just asked about orphaned orders, build javascript for that.
if (!isset($_GET['attachid'])) {
$ares = sqlStatement(
"SELECT procedure_order_id, date_ordered " .
"FROM procedure_order WHERE " .
"patient_id = ? AND encounter_id = 0 AND activity = 1 " .
"ORDER BY procedure_order_id",
array($pid)
);
echo " // Ask about attaching orphaned orders to this encounter.\n";
echo " var attachid = '';\n";
while ($arow = sqlFetchArray($ares)) {
$orderid = $arow['procedure_order_id'];
$orderdate = $arow['date_ordered'];
echo " if (confirm('" . xls('There is a lab order') . " $orderid " .
xls('dated') . " $orderdate " .
xls('for this patient not yet assigned to any encounter.') . " " .
xls('Assign it to this one?') . "')) attachid += '$orderid,';\n";
}
echo " if (attachid) location.href = 'forms.php?attachid=' + attachid;\n";
}
?>
<?php if ($reviewMode) { ?>
$("body table:first").hide();
$(".encounter-summary-column").hide();
$(".css_button").hide();
$(".css_button_small").hide();
$(".encounter-summary-column:first").show();
$(".title:first").text("<?php echo xls("Review"); ?> " + $(".title:first").text() + " ( <?php echo addslashes($encounter); ?> )");
<?php } ?>
});
// Process click on Delete link.
function deleteme() {
dlgopen('../deleter.php?encounterid=<?php echo $encounter; ?>', '_blank', 500, 200, '', '', {
buttons: [
{text: '<?php echo xla('Done'); ?>', close: true, style: 'primary btn-sm'}
],
allowResize: false,
allowDrag: true,
});
return false;
}
// Called by the deleter.php window on a successful delete.
function imdeleted(EncounterId) {
top.window.parent.left_nav.removeOptionSelected(EncounterId);
top.window.parent.left_nav.clearEncounter();
if (top.tab_mode) {
top.encounterList();
} else {
top.window.parent.left_nav.loadFrame('ens1', window.parent.name, 'patient_file/history/encounters.php');
}
}
// Called to open the data entry form a specified encounter form instance.
function openEncounterForm(formdir, formname, formid) {
var url = '<?php echo "$rootdir/patient_file/encounter/view_form.php?formname=" ?>' +
formdir + '&id=' + formid;
if (formdir == 'newpatient' || !parent.twAddFrameTab) {
top.restoreSession();
location.href = url;
}
else {
parent.twAddFrameTab('enctabs', formname, url);
}
return false;
}
// Called when an encounter form may changed something that requires a refresh here.
function refreshVisitDisplay() {
location.href = '<?php echo $rootdir; ?>/patient_file/encounter/forms.php';
}
</script>
<script language="javascript">
function expandcollapse(atr) {
for (var i = 1; i < 15; ++i) {
var mydivid="divid_" + i; var myspanid = "spanid_" + i;
var ele = document.getElementById(mydivid);
var text = document.getElementById(myspanid);
if (!ele) continue;
if (atr == "expand") {
ele.style.display = "block"; text.innerHTML = "<?php xl('Collapse', 'e'); ?>";
}
else {
ele.style.display = "none" ; text.innerHTML = "<?php xl('Expand', 'e'); ?>";
}
}
}
function divtoggle(spanid, divid) {
var ele = document.getElementById(divid);
var text = document.getElementById(spanid);
if(ele.style.display == "block") {
ele.style.display = "none";
text.innerHTML = "<?php xl('Expand', 'e'); ?>";
}
else {
ele.style.display = "block";
text.innerHTML = "<?php xl('Collapse', 'e'); ?>";
}
}
</script>
<style type="text/css">
div.tab {
min-height: 50px;
padding:8px;
}
div.form_header {
float:left;
min-width:300pt;
}
div.form_header_controls {
float:left;
margin-bottom:2px;
margin-left:6px;
}
div.formname {
float:left;
min-width:120pt;
font-weight:bold;
padding:0px;
margin:0px;
}
.encounter-summary-container {
float:left;
width:100%;
}
.encounter-summary-column {
width: 33.3%;
float:left;
display:inline;
margin-top:10px;
}
</style>
<!-- *************** -->
<!-- Form menu start -->
<script language="JavaScript">
function openNewForm(sel, label) {
top.restoreSession();
var FormNameValueArray = sel.split('formname=');
if (FormNameValueArray[1] == 'newpatient') {
// TBD: Make this work when it's not the first frame.
parent.frames[0].location.href = sel;
}
else {
parent.twAddFrameTab('enctabs', label, sel);
}
}
function toggleFrame1(fnum) {
top.frames['left_nav'].document.forms[0].cb_top.checked=false;
top.window.parent.left_nav.toggleFrame(fnum);
}
</script>
<style type="text/css">
#sddm
{ margin: 0;
padding: 0;
z-index: 30;
}
</style>
<script type="text/javascript" language="javascript">
var timeout = 500;
var closetimer = 0;
var ddmenuitem = 0;
var oldddmenuitem = 0;
var flag = 0;
// open hidden layer
function mopen(id)
{
// cancel close timer
//mcancelclosetime();
flag=10;
// close old layer
//if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
//if(ddmenuitem) ddmenuitem.style.display = 'none';
// get new layer and show it
oldddmenuitem = ddmenuitem;
ddmenuitem = document.getElementById(id);
if((ddmenuitem.style.visibility == '')||(ddmenuitem.style.visibility == 'hidden')){
if(oldddmenuitem) oldddmenuitem.style.visibility = 'hidden';
if(oldddmenuitem) oldddmenuitem.style.display = 'none';
ddmenuitem.style.visibility = 'visible';
ddmenuitem.style.display = 'block';
}else{
ddmenuitem.style.visibility = 'hidden';
ddmenuitem.style.display = 'none';
}
}
// close showed layer
function mclose()
{
if(flag==10)
{
flag=11;
return;
}
if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
if(ddmenuitem) ddmenuitem.style.display = 'none';
}
// close layer when click-out
document.onclick = mclose;
//=================================================
function findPosX(id)
{
obj=document.getElementById(id);
var curleft = 0;
if(obj.offsetParent)
while(1)
{
curleft += obj.offsetLeft;
if(!obj.offsetParent)
break;
obj = obj.offsetParent;
}
else if(obj.x)
curleft += obj.x;
PropertyWidth=document.getElementById(id).offsetWidth;
if(PropertyWidth>curleft)
{
document.getElementById(id).style.left=0;
}
}
function findPosY(obj)
{
var curtop = 0;
if(obj.offsetParent)
while(1)
{
curtop += obj.offsetTop;
if(!obj.offsetParent)
break;
obj = obj.offsetParent;
}
else if(obj.y)
curtop += obj.y;
return curtop;
}
</script>
</head>
<body class="bgcolor2">
<dl>
<?php //DYNAMIC FORM RETREIVAL
include_once("$srcdir/registry.inc");
function myGetRegistered($state = "1", $limit = "unlimited", $offset = "0")
{
global $attendant_type;
$sql = "SELECT category, nickname, name, state, directory, id, sql_run, " .
"unpackaged, date, aco_spec FROM registry WHERE ";
// select different forms for groups
if ($attendant_type == 'pid') {
$sql .= "patient_encounter = 1 AND ";
} else {
$sql .= "therapy_group_encounter = 1 AND ";
}
$sql .= "state LIKE \"$state\" ORDER BY category, priority, name";
if ($limit != "unlimited") {
$sql .= " limit $limit, $offset";
}
$res = sqlStatement($sql);
if ($res) {
for ($iter=0; $row=sqlFetchArray($res); $iter++) {
$all[$iter] = $row;
}
} else {
return false;
}
return $all;
}
$reg = myGetRegistered();
$old_category = '';
$DivId=1;
// To see if the encounter is locked. If it is, no new forms can be created
$encounterLocked = false;
if ($esignApi->lockEncounters() &&
isset($GLOBALS['encounter']) &&
!empty($GLOBALS['encounter']) ) {
$esign = $esignApi->createEncounterESign($GLOBALS['encounter']);
if ($esign->isLocked()) {
$encounterLocked = true;
}
}
if (!empty($reg)) {
$StringEcho= '<ul id="sddm">';
if ($encounterLocked === false) {
foreach ($reg as $entry) {
// Check permission to create forms of this type.
$tmp = explode('|', $entry['aco_spec']);
if (!empty($tmp[1])) {
if (!acl_check($tmp[0], $tmp[1], '', 'write') && !acl_check($tmp[0], $tmp[1], '', 'addonly')) {
continue;
}
}
$new_category = trim($entry['category']);
$new_nickname = trim($entry['nickname']);
if ($new_category == '') {
$new_category = htmlspecialchars(xl('Miscellaneous'), ENT_QUOTES);
} else {
$new_category = htmlspecialchars(xl($new_category), ENT_QUOTES);
}
if ($new_nickname != '') {
$nickname = $new_nickname;
} else {
$nickname = trim($entry['name']);
}
if ($old_category != $new_category) {
$new_category_ = $new_category;
$new_category_ = str_replace(' ', '_', $new_category_);
if ($old_category != '') {
$StringEcho .= "</table></div></li>";
}
$StringEcho .= "<li class=\"encounter-form-category-li\"><a href='JavaScript:void(0);' onClick=\"mopen('$DivId');\" >$new_category</a><div id='$DivId' ><table border='0' cellspacing='0' cellpadding='0'>";
$old_category = $new_category;
$DivId++;
}
$StringEcho .= "<tr><td style='border-top: 1px solid #000000;padding:0px;'><a onclick=\"openNewForm('" .
$rootdir . "/patient_file/encounter/load_form.php?formname=" . urlencode($entry['directory']) .
"', '" . addslashes(xl_form_title($nickname)) . "')\" href='JavaScript:void(0);'>" .
text(xl_form_title($nickname)) . "</a></td></tr>";
}
}
$StringEcho.= '</table></div></li>';
}
if ($StringEcho) {
$StringEcho2= '<div style="clear:both"></div>';
} else {
$StringEcho2="";
}
// This shows Layout Based Form names just like the above.
//
if ($encounterLocked === false) {
$lres = sqlStatement("SELECT grp_form_id AS option_id, grp_title AS title, grp_aco_spec " .
"FROM layout_group_properties WHERE " .
"grp_form_id LIKE 'LBF%' AND grp_group_id = '' AND grp_activity = 1 " .
"ORDER BY grp_seq, grp_title");
if (sqlNumRows($lres)) {
if (!$StringEcho) {
$StringEcho= '<ul id="sddm">';
}
$StringEcho.= "<li class=\"encounter-form-category-li\"><a href='JavaScript:void(0);' onClick=\"mopen('lbf');\" >" .
xl('Layout Based') . "</a><div id='lbf' ><table border='0' cellspacing='0' cellpadding='0'>";
while ($lrow = sqlFetchArray($lres)) {
$option_id = $lrow['option_id']; // should start with LBF
$title = $lrow['title'];
// Check ACO attribute, if any, of this LBF.
if (!empty($lrow['grp_aco_spec'])) {
$tmp = explode('|', $lrow['grp_aco_spec']);
if (!acl_check($tmp[0], $tmp[1], '', 'write') && !acl_check($tmp[0], $tmp[1], '', 'addonly')) {
continue;
}
}
$StringEcho .= "<tr><td style='border-top: 1px solid #000000;padding:0px;'><a onclick=\"openNewForm('" .
$rootdir . "/patient_file/encounter/load_form.php?formname=" . urlencode($option_id) .
"', '" . addslashes(xl_form_title($title)) . "')\" href='JavaScript:void(0);'>" .
text(xl_form_title($title)) . "</a></td></tr>";
}
}
}
?>
<!-- DISPLAYING HOOKS STARTS HERE -->
<?php
$module_query = sqlStatement("SELECT msh.*,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='encounter' 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'];
}
$relative_link = "../../modules/".$modulePath."/".$modulerow['path'];
$nickname = $modulerow['menu_name'] ? $modulerow['menu_name'] : 'Noname';
if ($jid==0 || ($modid!=$modulerow['mod_id'])) {
if ($modid!='') {
$StringEcho.= '</table></div></li>';
}
$StringEcho.= "<li><a href='JavaScript:void(0);' onClick=\"mopen('$DivId');\" >$new_category</a><div id='$DivId' ><table border='0' cellspacing='0' cellpadding='0'>";
}
$jid++;
$modid = $modulerow['mod_id'];
$StringEcho.= "<tr><td style='border-top: 1px solid #000000;padding:0px;'><a onclick=" .
"\"openNewForm('$relative_link', '" . addslashes(xl_form_title($nickname)) . "')\" " .
"href='JavaScript:void(0);'>" . xl_form_title($nickname) . "</a></td></tr>";
}
}
?>
<!-- DISPLAYING HOOKS ENDS HERE -->
<?php
if ($StringEcho) {
$StringEcho.= "</table></div></li></ul>".$StringEcho2;
}
?>
<table cellspacing="0" cellpadding="0" align="center">
<tr>
<td valign="top"><?php echo $StringEcho; ?></td>
</tr>
</table>
</dl>
<!-- Form menu stop -->
<!-- *************** -->
<div id="encounter_forms">
<?php
$dateres = getEncounterDateByEncounter($encounter);
$encounter_date = date("Y-m-d", strtotime($dateres["date"]));
$providerIDres = getProviderIdOfEncounter($encounter);
$providerNameRes = getProviderName($providerIDres);
?>
<div class='encounter-summary-container'>
<div class='encounter-summary-column'>
<div>
<?php
$pass_sens_squad = true;
//fetch acl for category of given encounter
$pc_catid = fetchCategoryIdByEncounter($encounter);
$postCalendarCategoryACO = fetchPostCalendarCategoryACO($pc_catid);
if ($postCalendarCategoryACO) {
$postCalendarCategoryACO = explode('|', $postCalendarCategoryACO);
$authPostCalendarCategory = acl_check($postCalendarCategoryACO[0], $postCalendarCategoryACO[1]);
$authPostCalendarCategoryWrite = acl_check($postCalendarCategoryACO[0], $postCalendarCategoryACO[1], '', 'write');
} else { // if no aco is set for category
$authPostCalendarCategory = true;
$authPostCalendarCategoryWrite = true;
}
if ($attendant_type == 'pid' && is_numeric($pid)) {
echo '<span class="title">' . text(oeFormatShortDate($encounter_date)) . " " . xlt("Encounter") . '</span>';
// Check for no access to the patient's squad.
$result = getPatientData($pid, "fname,lname,squad");
echo htmlspecialchars(xl('for', '', ' ', ' ') . $result['fname'] . " " . $result['lname']);
if ($result['squad'] && ! acl_check('squads', $result['squad'])) {
$pass_sens_squad = false;
}
// Check for no access to the encounter's sensitivity level.
$result = sqlQuery("SELECT sensitivity FROM form_encounter WHERE " .
"pid = '$pid' AND encounter = '$encounter' LIMIT 1");
if (($result['sensitivity'] && !acl_check('sensitivities', $result['sensitivity'])) || !$authPostCalendarCategory) {
$pass_sens_squad = false;
}
// for therapy group
} else {
echo '<span class="title">' . text(oeFormatShortDate($encounter_date)) . " " . xlt("Group Encounter") . '</span>';
// Check for no access to the patient's squad.
$result = getGroup($groupId);
echo htmlspecialchars(xl('for ', '', ' ', ' ') . $result['group_name']);
if ($result['squad'] && ! acl_check('squads', $result['squad'])) {
$pass_sens_squad = false;
}
// Check for no access to the encounter's sensitivity level.
$result = sqlQuery("SELECT sensitivity FROM form_groups_encounter WHERE " .
"group_id = ? AND encounter = ? LIMIT 1", array($groupId, $encounter));
if (($result['sensitivity'] && !acl_check('sensitivities', $result['sensitivity'])) || !$authPostCalendarCategory) {
$pass_sens_squad = false;
}
}
?>
</div>
<div style='margin-top:8px;'>
<?php
// ESign for entire encounter
$esign = $esignApi->createEncounterESign($encounter);
if ($esign->isButtonViewable()) {
echo $esign->buttonHtml();
}
?>
<?php if (acl_check('admin', 'super')) { ?>
<a href='#' class='css_button' onclick='return deleteme()'><span><?php echo xl('Delete') ?></span></a>
<?php } ?>
<a href="#" onClick='expandcollapse("expand");' style="font-size:80%;"><?php xl('Expand All', 'e'); ?></a>
<a style="font-size:80%;" href="#" onClick='expandcollapse("collapse");'><?php xl('Collapse All', 'e'); ?></a>
</div>
</div>
<div class='encounter-summary-column'>
<?php if ($esign->isLogViewable()) {
$esign->renderLog();
} ?>
</div>
<div class='encounter-summary-column'>
<?php if ($GLOBALS['enable_amc_prompting']) { ?>
<div style='float:right;margin-right:25px;border-style:solid;border-width:1px;'>
<div style='float:left;margin:5px 5px 5px 5px;'>
<table>
<tr>
<td>
<?php // Display the education resource checkbox (AMC prompting)
$itemAMC = amcCollect("patient_edu_amc", $pid, 'form_encounter', $encounter);
?>
<?php if (!(empty($itemAMC))) { ?>
<input type="checkbox" id="prov_edu_res" checked>
<?php } else { ?>
<input type="checkbox" id="prov_edu_res">
<?php } ?>
</td>
<td>
<span class="text"><?php echo xl('Provided Education Resource(s)?') ?></span>
</td>
</tr>
<tr>
<td>
<?php // Display the Provided Clinical Summary checkbox (AMC prompting)
$itemAMC = amcCollect("provide_sum_pat_amc", $pid, 'form_encounter', $encounter);
?>
<?php if (!(empty($itemAMC))) { ?>
<input type="checkbox" id="provide_sum_pat_flag" checked>
<?php } else { ?>
<input type="checkbox" id="provide_sum_pat_flag">
<?php } ?>
</td>
<td>
<span class="text"><?php echo xl('Provided Clinical Summary?') ?></span>
</td>
</tr>
<?php // Display the medication reconciliation checkboxes (AMC prompting)
$itemAMC = amcCollect("med_reconc_amc", $pid, 'form_encounter', $encounter);
?>
<?php if (!(empty($itemAMC))) { ?>
<tr>
<td>
<input type="checkbox" id="trans_trand_care" checked>
</td>
<td>
<span class="text"><?php echo xl('Transition/Transfer of Care?') ?></span>
</td>
</tr>
</table>
<table style="margin-left:2em;">
<tr>
<td>
<?php if (!(empty($itemAMC['date_completed']))) { ?>
<input type="checkbox" id="med_reconc_perf" checked>
<?php } else { ?>
<input type="checkbox" id="med_reconc_perf">
<?php } ?>
</td>
<td>
<span class="text"><?php echo xl('Medication Reconciliation Performed?') ?></span>
</td>
</tr>
<tr>
<td>
<?php if (!(empty($itemAMC['soc_provided']))) { ?>
<input type="checkbox" id="soc_provided" checked>
<?php } else { ?>
<input type="checkbox" id="soc_provided">
<?php } ?>
</td>
<td>
<span class="text"><?php echo xl('Summary Of Care Provided?') ?></span>
</td>
</tr>
</table>
<?php } else { ?>
<tr>
<td>
<input type="checkbox" id="trans_trand_care">
</td>
<td>
<span class="text"><?php echo xl('Transition/Transfer of Care?') ?></span>
</td>
</tr>
</table>
<table style="margin-left:2em;">
<tr>
<td>
<input type="checkbox" id="med_reconc_perf" DISABLED>
</td>
<td>
<span class="text"><?php echo xl('Medication Reconciliation Performed?') ?></span>
</td>
</tr>
<tr>
<td>
<input type="checkbox" id="soc_provided" DISABLED>
</td>
<td>
<span class="text"><?php echo xl('Summary of Care Provided?') ?></span>
</td>
</tr>
</table>
<?php } ?>
</div>
</div>
<?php } ?>
</div>
</div>
<!-- Get the documents tagged to this encounter and display the links and notes as the tooltip -->
<?php
if ($attendant_type == 'pid') {
$docs_list = getDocumentsByEncounter($pid, $_SESSION['encounter']);
} else {
// already doesn't exist document for therapy groups
$docs_list = array();
}
if (!empty($docs_list) && count($docs_list) > 0) {
?>
<div class='enc_docs'>
<span class="bold"><?php echo xlt("Document(s)"); ?>:</span>
<?php
$doc = new C_Document();
foreach ($docs_list as $doc_iter) {
$doc_url = $doc->_tpl_vars[CURRENT_ACTION]. "&view&patient_id=".attr($pid)."&document_id=" . attr($doc_iter[id]) . "&";
// Get notes for this document.
$queryString = "SELECT GROUP_CONCAT(note ORDER BY date DESC SEPARATOR '|') AS docNotes, GROUP_CONCAT(date ORDER BY date DESC SEPARATOR '|') AS docDates
FROM notes WHERE foreign_id = ? GROUP BY foreign_id";
$noteData = sqlQuery($queryString, array($doc_iter[id]));
$note = '';
if ($noteData) {
$notes = array();
$notes = explode("|", $noteData['docNotes']);
$dates = explode("|", $noteData['docDates']);
for ($i = 0; $i < count($notes); $i++) {
$note .= oeFormatShortDate(date('Y-m-d', strtotime($dates[$i]))) . " : " . $notes[$i] . "\n";
}
}
?>
<br>
<a href="<?php echo $doc_url;?>" style="font-size:small;" onsubmit="return top.restoreSession()"><?php echo text(oeFormatShortDate($doc_iter[docdate])) . ": " . text(basename($doc_iter[url]));?></a>
<?php if ($note != '') {?>
<a href="javascript:void(0);" title="<?php echo attr($note);?>"><img src="../../../images/info.png"/></a>
<?php }?>
<?php } ?>
</div>
<?php } ?>
<br/>
<?php
if ($pass_sens_squad &&
($result = getFormByEncounter(
$attendant_id,
$encounter,
"id, date, form_id, form_name, formdir, user, deleted",
"",
"FIND_IN_SET(formdir,'newpatient') DESC, form_name, date DESC"
))) {
echo "<table width='100%' id='partable'>";
$divnos = 1;
foreach ($result as $iter) {
$formdir = $iter['formdir'];
// skip forms whose 'deleted' flag is set to 1
if ($iter['deleted'] == 1) {
continue;
}
$aco_spec = false;
if (substr($formdir, 0, 3) == 'LBF') {
// Skip LBF forms that we are not authorized to see.
$lrow = sqlQuery(
"SELECT grp_aco_spec " .
"FROM layout_group_properties WHERE " .
"grp_form_id = ? AND grp_group_id = '' AND grp_activity = 1",
array($formdir)
);
if (!empty($lrow)) {
if (!empty($lrow['grp_aco_spec'])) {
$aco_spec = explode('|', $lrow['grp_aco_spec']);
if (!acl_check($aco_spec[0], $aco_spec[1])) {
continue;
}
}
}
} else {
// Skip non-LBF forms that we are not authorized to see.
$tmp = getRegistryEntryByDirectory($formdir, 'aco_spec');
if (!empty($tmp['aco_spec'])) {
$aco_spec = explode('|', $tmp['aco_spec']);
if (!acl_check($aco_spec[0], $aco_spec[1])) {
continue;
}
}
}
// $form_info = getFormInfoById($iter['id']);
if (strtolower(substr($iter['form_name'], 0, 5)) == 'camos') {
//CAMOS generates links from report.php and these links should
//be clickable without causing view.php to come up unexpectedly.
//I feel that the JQuery code in this file leading to a click
//on the report.php content to bring up view.php steps on a
//form's autonomy to generate it's own html content in it's report
//but until any other form has a problem with this, I will just
//make an exception here for CAMOS and allow it to carry out this
//functionality for all other forms. --Mark
echo '<tr title="' . xl('Edit form') . '" '.
'id="'.$formdir.'~'.$iter['form_id'].'">';
} else {
echo '<tr id="' . $formdir . '~' . $iter['form_id'] . '" class="text onerow">';
}
$acl_groups = acl_check("groups", "glog", false, 'write') ? true : false;
$user = getNameFromUsername($iter['user']);
$form_name = ($formdir == 'newpatient') ? xl('Visit Summary') : xl_form_title($iter['form_name']);
// Create the ESign instance for this form
$esign = $esignApi->createFormESign($iter['id'], $formdir, $encounter);
// echo "<tr>"; // Removed as bug fix.
echo "<td style='border-bottom:1px solid'>";
// Figure out the correct author (encounter authors are the '$providerNameRes', while other
// form authors are the '$user['fname'] . " " . $user['lname']').
if ($formdir == 'newpatient') {
$form_author = $providerNameRes;
} else {
$form_author = $user['fname'] . " " . $user['lname'];
}
echo "<div class='form_header'>";
echo "<a href='#' onclick='divtoggle(\"spanid_$divnos\",\"divid_$divnos\");' class='small' id='aid_$divnos'>" .
"<div class='formname'>" . text($form_name) . "</div> " .
xlt('by') . " " . text($form_author) . " " .
"(<span id=spanid_$divnos class=\"indicator\">" . ($divnos == 1 ? xlt('Collapse') : xlt('Expand')) . "</span>)</a>";
echo "</div>";