fix link to edit encounter's forms screen
[openemr.git] / interface / patient_file / encounter / forms.php
blobd279ecc503107377740cb62e0fb1016f87baa287
1 <?php
2 use ESign\Api;
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
9 require_once("../../globals.php");
10 require_once("$srcdir/encounter.inc");
11 require_once("$srcdir/group.inc");
12 require_once("$srcdir/calendar.inc");
13 require_once("$srcdir/acl.inc");
14 require_once("$srcdir/patient.inc");
15 require_once("$srcdir/amc.php");
16 require_once $GLOBALS['srcdir'].'/ESign/Api.php';
17 require_once("$srcdir/../controllers/C_Document.class.php");
19 $reviewMode = false;
20 if (!empty($_REQUEST['review_id'])) {
21 $reviewMode = true;
22 $encounter=$_REQUEST['review_id'];
25 $is_group = ($attendant_type == 'gid') ? true : false;
26 if ($attendant_type == 'gid') {
27 $groupId = $therapy_group;
29 $attendant_id = $attendant_type == 'pid' ? $pid : $therapy_group;
30 if ($is_group && !acl_check("groups", "glog", false, array('view','write'))) {
31 echo xlt("access not allowed");
32 exit();
36 <html>
38 <head>
40 <?php require $GLOBALS['srcdir'] . '/js/xl/dygraphs.js.php'; ?>
42 <?php html_header_show();?>
43 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
44 <link rel="stylesheet" type="text/css" href="<?php echo $GLOBALS['webroot'] ?>/library/ESign/css/esign.css" />
45 <link rel="stylesheet" href="<?php echo $GLOBALS['assets_static_relative']; ?>/modified/dygraphs-2-0-0/dygraph.css" type="text/css"></script>
47 <!-- supporting javascript code -->
48 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-3-1-1/index.js"></script>
49 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/dialog.js?v=<?php echo $v_js_includes; ?>"></script>
50 <script type="text/javascript" src="../../../library/textformat.js"></script>
51 <script type="text/javascript" src="../../../library/js/common.js"></script>
52 <script src="<?php echo $GLOBALS['webroot'] ?>/library/ESign/js/jquery.esign.js"></script>
53 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/modified/dygraphs-2-0-0/dygraph.js?v=<?php echo $v_js_includes; ?>"></script>
55 <?php
56 $esignApi = new Api();
59 <?php // if the track_anything form exists, then include the styling and js functions for graphing
60 if (file_exists(dirname(__FILE__) . "/../../forms/track_anything/style.css")) { ?>
61 <script type="text/javascript" src="<?php echo $GLOBALS['web_root']?>/interface/forms/track_anything/report.js"></script>
62 <link rel="stylesheet" href="<?php echo $GLOBALS['web_root']?>/interface/forms/track_anything/style.css" type="text/css">
63 <?php } ?>
65 <?php
66 // If the user requested attachment of any orphaned procedure orders, do it.
67 if (!empty($_GET['attachid'])) {
68 $attachid = explode(',', $_GET['attachid']);
69 foreach ($attachid as $aid) {
70 $aid = intval($aid);
71 if (!$aid) {
72 continue;
74 $tmp = sqlQuery(
75 "SELECT COUNT(*) AS count FROM procedure_order WHERE " .
76 "procedure_order_id = ? AND patient_id = ? AND encounter_id = 0 AND activity = 1",
77 array($aid, $pid)
79 if (!empty($tmp['count'])) {
80 sqlStatement(
81 "UPDATE procedure_order SET encounter_id = ? WHERE " .
82 "procedure_order_id = ? AND patient_id = ? AND encounter_id = 0 AND activity = 1",
83 array($encounter, $aid, $pid)
85 addForm($encounter, "Procedure Order", $aid, "procedure_order", $pid, $userauthorized);
91 <script type="text/javascript">
92 $.noConflict();
93 jQuery(document).ready( function($) {
94 var formConfig = <?php echo $esignApi->formConfigToJson(); ?>;
95 $(".esign-button-form").esign(
96 formConfig,
98 afterFormSuccess : function( response ) {
99 if ( response.locked ) {
100 var editButtonId = "form-edit-button-"+response.formDir+"-"+response.formId;
101 $("#"+editButtonId).replaceWith( response.editButtonHtml );
104 var logId = "esign-signature-log-"+response.formDir+"-"+response.formId;
105 $.post( formConfig.logViewAction, response, function( html ) {
106 $("#"+logId).replaceWith( html );
112 var encounterConfig = <?php echo $esignApi->encounterConfigToJson(); ?>;
113 $(".esign-button-encounter").esign(
114 encounterConfig,
116 afterFormSuccess : function( response ) {
117 // If the response indicates a locked encounter, replace all
118 // form edit buttons with a "disabled" button, and "disable" left
119 // nav visit form links
120 if ( response.locked ) {
121 // Lock the form edit buttons
122 $(".form-edit-button").replaceWith( response.editButtonHtml );
123 // Disable the new-form capabilities in left nav
124 top.window.parent.left_nav.syncRadios();
125 // Disable the new-form capabilities in top nav of the encounter
126 $(".encounter-form-category-li").remove();
129 var logId = "esign-signature-log-encounter-"+response.encounterId;
130 $.post( encounterConfig.logViewAction, response, function( html ) {
131 $("#"+logId).replaceWith( html );
137 $(".onerow").mouseover(function() { $(this).toggleClass("highlight"); });
138 $(".onerow").mouseout(function() { $(this).toggleClass("highlight"); });
139 $(".onerow").click(function() { GotoForm(this); });
141 $("#prov_edu_res").click(function() {
142 if ( $('#prov_edu_res').prop('checked') ) {
143 var mode = "add";
145 else {
146 var mode = "remove";
148 top.restoreSession();
149 $.post( "../../../library/ajax/amc_misc_data.php",
150 { amc_id: "patient_edu_amc",
151 complete: true,
152 mode: mode,
153 patient_id: <?php echo htmlspecialchars($pid, ENT_NOQUOTES); ?>,
154 object_category: "form_encounter",
155 object_id: <?php echo htmlspecialchars($encounter, ENT_NOQUOTES); ?>
160 $("#provide_sum_pat_flag").click(function() {
161 if ( $('#provide_sum_pat_flag').prop('checked') ) {
162 var mode = "add";
164 else {
165 var mode = "remove";
167 top.restoreSession();
168 $.post( "../../../library/ajax/amc_misc_data.php",
169 { amc_id: "provide_sum_pat_amc",
170 complete: true,
171 mode: mode,
172 patient_id: <?php echo htmlspecialchars($pid, ENT_NOQUOTES); ?>,
173 object_category: "form_encounter",
174 object_id: <?php echo htmlspecialchars($encounter, ENT_NOQUOTES); ?>
179 $("#trans_trand_care").click(function() {
180 if ( $('#trans_trand_care').prop('checked') ) {
181 var mode = "add";
182 // Enable the reconciliation checkbox
183 $("#med_reconc_perf").removeAttr("disabled");
184 $("#soc_provided").removeAttr("disabled");
186 else {
187 var mode = "remove";
188 //Disable the reconciliation checkbox (also uncheck it if applicable)
189 $("#med_reconc_perf").attr("disabled", true);
190 $("#med_reconc_perf").prop("checked",false);
191 $("#soc_provided").attr("disabled",true);
192 $("#soc_provided").prop("checked",false);
194 top.restoreSession();
195 $.post( "../../../library/ajax/amc_misc_data.php",
196 { amc_id: "med_reconc_amc",
197 complete: false,
198 mode: mode,
199 patient_id: <?php echo htmlspecialchars($pid, ENT_NOQUOTES); ?>,
200 object_category: "form_encounter",
201 object_id: <?php echo htmlspecialchars($encounter, ENT_NOQUOTES); ?>
206 $("#med_reconc_perf").click(function() {
207 if ( $('#med_reconc_perf').prop('checked') ) {
208 var mode = "complete";
210 else {
211 var mode = "uncomplete";
213 top.restoreSession();
214 $.post( "../../../library/ajax/amc_misc_data.php",
215 { amc_id: "med_reconc_amc",
216 complete: true,
217 mode: mode,
218 patient_id: <?php echo htmlspecialchars($pid, ENT_NOQUOTES); ?>,
219 object_category: "form_encounter",
220 object_id: <?php echo htmlspecialchars($encounter, ENT_NOQUOTES); ?>
224 $("#soc_provided").click(function(){
225 if($('#soc_provided').prop('checked')){
226 var mode = "soc_provided";
228 else{
229 var mode = "no_soc_provided";
231 top.restoreSession();
232 $.post( "../../../library/ajax/amc_misc_data.php",
233 { amc_id: "med_reconc_amc",
234 complete: true,
235 mode: mode,
236 patient_id: <?php echo htmlspecialchars($pid, ENT_NOQUOTES); ?>,
237 object_category: "form_encounter",
238 object_id: <?php echo htmlspecialchars($encounter, ENT_NOQUOTES); ?>
243 $(".deleteme").click(function(evt) { deleteme(); evt.stopPropogation(); });
245 var GotoForm = function(obj) {
246 var parts = $(obj).attr("id").split("~");
247 top.restoreSession();
248 parent.location.href = "<?php echo $rootdir; ?>/patient_file/encounter/view_form.php?formname="+parts[0]+"&id="+parts[1];
251 <?php
252 // If the user was not just asked about orphaned orders, build javascript for that.
253 if (!isset($_GET['attachid'])) {
254 $ares = sqlStatement(
255 "SELECT procedure_order_id, date_ordered " .
256 "FROM procedure_order WHERE " .
257 "patient_id = ? AND encounter_id = 0 AND activity = 1 " .
258 "ORDER BY procedure_order_id",
259 array($pid)
261 echo " // Ask about attaching orphaned orders to this encounter.\n";
262 echo " var attachid = '';\n";
263 while ($arow = sqlFetchArray($ares)) {
264 $orderid = $arow['procedure_order_id'];
265 $orderdate = $arow['date_ordered'];
266 echo " if (confirm('" . xls('There is a lab order') . " $orderid " .
267 xls('dated') . " $orderdate " .
268 xls('for this patient not yet assigned to any encounter.') . " " .
269 xls('Assign it to this one?') . "')) attachid += '$orderid,';\n";
271 echo " if (attachid) location.href = 'forms.php?attachid=' + attachid;\n";
275 <?php if ($reviewMode) { ?>
276 $("body table:first").hide();
277 $(".encounter-summary-column").hide();
278 $(".css_button").hide();
279 $(".css_button_small").hide();
280 $(".encounter-summary-column:first").show();
281 $(".title:first").text("<?php echo xls("Review"); ?> " + $(".title:first").text() + " ("+<?php echo addslashes($encounter); ?>+")");
282 <?php } ?>
285 // Process click on Delete link.
286 function deleteme() {
287 dlgopen('../deleter.php?encounterid=<?php echo $encounter; ?>', '_blank', 500, 450);
288 return false;
291 // Called by the deleter.php window on a successful delete.
292 function imdeleted(EncounterId) {
293 top.window.parent.left_nav.removeOptionSelected(EncounterId);
294 top.window.parent.left_nav.clearEncounter();
297 </script>
299 <script language="javascript">
300 function expandcollapse(atr){
301 if(atr == "expand") {
302 for(i=1;i<15;i++){
303 var mydivid="divid_"+i;var myspanid="spanid_"+i;
304 var ele = document.getElementById(mydivid); var text = document.getElementById(myspanid);
305 if (typeof(ele) != 'undefined' && ele != null)
306 ele.style.display = "block";
307 if (typeof(text) != 'undefined' && text != null)
308 text.innerHTML = "<?php xl('Collapse', 'e'); ?>";
311 else {
312 for(i=1;i<15;i++){
313 var mydivid="divid_"+i;var myspanid="spanid_"+i;
314 var ele = document.getElementById(mydivid); var text = document.getElementById(myspanid);
315 if (typeof(ele) != 'undefined' && ele != null)
316 ele.style.display = "none";
317 if (typeof(text) != 'undefined' && text != null)
318 text.innerHTML = "<?php xl('Expand', 'e'); ?>";
324 function divtoggle(spanid, divid) {
325 var ele = document.getElementById(divid);
326 var text = document.getElementById(spanid);
327 if(ele.style.display == "block") {
328 ele.style.display = "none";
329 text.innerHTML = "<?php xl('Expand', 'e'); ?>";
331 else {
332 ele.style.display = "block";
333 text.innerHTML = "<?php xl('Collapse', 'e'); ?>";
336 </script>
338 <style type="text/css">
339 div.tab {
340 min-height: 50px;
341 padding:8px;
344 div.form_header_controls {
345 float:left;margin-bottom:2px;
348 div.form_header {
349 float:left;
350 margin-left:6px;
353 .encounter-summary-container {
354 float:left;
355 width:100%;
358 .encounter-summary-column {
359 width: 33.3%;
360 float:left;
361 display:inline;
362 margin-top:10px;
364 </style>
366 <!-- *************** -->
367 <!-- Form menu start -->
368 <script language="JavaScript">
370 function openNewForm(sel) {
371 top.restoreSession();
372 FormNameValueArray = sel.split('formname=');
373 if(FormNameValueArray[1] == 'newpatient' || FormNameValueArray[1] == 'newGroupEncounter')
375 parent.location.href = sel;
377 else if (!parent.Forms)
379 location.href = sel;
381 else
383 parent.Forms.location.href = sel;
387 function toggleFrame1(fnum) {
388 top.frames['left_nav'].document.forms[0].cb_top.checked=false;
389 top.window.parent.left_nav.toggleFrame(fnum);
391 </script>
392 <style type="text/css">
393 #sddm
394 { margin: 0;
395 padding: 0;
396 z-index: 30;
399 </style>
400 <script type="text/javascript" language="javascript">
402 var timeout = 500;
403 var closetimer = 0;
404 var ddmenuitem = 0;
405 var oldddmenuitem = 0;
406 var flag = 0;
408 // open hidden layer
409 function mopen(id)
411 // cancel close timer
412 //mcancelclosetime();
414 flag=10;
416 // close old layer
417 //if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
418 //if(ddmenuitem) ddmenuitem.style.display = 'none';
420 // get new layer and show it
421 oldddmenuitem = ddmenuitem;
422 ddmenuitem = document.getElementById(id);
423 if((ddmenuitem.style.visibility == '')||(ddmenuitem.style.visibility == 'hidden')){
424 if(oldddmenuitem) oldddmenuitem.style.visibility = 'hidden';
425 if(oldddmenuitem) oldddmenuitem.style.display = 'none';
426 ddmenuitem.style.visibility = 'visible';
427 ddmenuitem.style.display = 'block';
428 }else{
429 ddmenuitem.style.visibility = 'hidden';
430 ddmenuitem.style.display = 'none';
433 // close showed layer
434 function mclose()
436 if(flag==10)
438 flag=11;
439 return;
441 if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
442 if(ddmenuitem) ddmenuitem.style.display = 'none';
445 // close layer when click-out
446 document.onclick = mclose;
447 //=================================================
448 function findPosX(id)
450 obj=document.getElementById(id);
451 var curleft = 0;
452 if(obj.offsetParent)
453 while(1)
455 curleft += obj.offsetLeft;
456 if(!obj.offsetParent)
457 break;
458 obj = obj.offsetParent;
460 else if(obj.x)
461 curleft += obj.x;
462 PropertyWidth=document.getElementById(id).offsetWidth;
463 if(PropertyWidth>curleft)
465 document.getElementById(id).style.left=0;
469 function findPosY(obj)
471 var curtop = 0;
472 if(obj.offsetParent)
473 while(1)
475 curtop += obj.offsetTop;
476 if(!obj.offsetParent)
477 break;
478 obj = obj.offsetParent;
480 else if(obj.y)
481 curtop += obj.y;
482 return curtop;
484 </script>
486 </head>
487 <body class="bgcolor2">
488 <dl>
489 <?php //DYNAMIC FORM RETREIVAL
490 include_once("$srcdir/registry.inc");
492 function myGetRegistered($state = "1", $limit = "unlimited", $offset = "0")
494 global $attendant_type;
495 $sql = "SELECT category, nickname, name, state, directory, id, sql_run, " .
496 "unpackaged, date, aco_spec FROM registry WHERE ";
497 // select different forms for groups
498 if ($attendant_type == 'pid') {
499 $sql .= "patient_encounter = 1 AND ";
500 } else {
501 $sql .= "therapy_group_encounter = 1 AND ";
503 $sql .= "state LIKE \"$state\" ORDER BY category, priority, name";
504 if ($limit != "unlimited") {
505 $sql .= " limit $limit, $offset";
507 $res = sqlStatement($sql);
508 if ($res) {
509 for ($iter=0; $row=sqlFetchArray($res); $iter++) {
510 $all[$iter] = $row;
512 } else {
513 return false;
515 return $all;
518 $reg = myGetRegistered();
519 $old_category = '';
521 $DivId=1;
523 // To see if the encounter is locked. If it is, no new forms can be created
524 $encounterLocked = false;
525 if ($esignApi->lockEncounters() &&
526 isset($GLOBALS['encounter']) &&
527 !empty($GLOBALS['encounter']) ) {
528 $esign = $esignApi->createEncounterESign($GLOBALS['encounter']);
529 if ($esign->isLocked()) {
530 $encounterLocked = true;
534 if (!empty($reg)) {
535 $StringEcho= '<ul id="sddm">';
536 if ($encounterLocked === false) {
537 foreach ($reg as $entry) {
538 // Check permission to create forms of this type.
539 $tmp = explode('|', $entry['aco_spec']);
540 if (!empty($tmp[1])) {
541 if (!acl_check($tmp[0], $tmp[1], '', 'write') && !acl_check($tmp[0], $tmp[1], '', 'addonly')) {
542 continue;
545 $new_category = trim($entry['category']);
546 $new_nickname = trim($entry['nickname']);
547 if ($new_category == '') {
548 $new_category = htmlspecialchars(xl('Miscellaneous'), ENT_QUOTES);
549 } else {
550 $new_category = htmlspecialchars(xl($new_category), ENT_QUOTES);
552 if ($new_nickname != '') {
553 $nickname = $new_nickname;} else {
554 $nickname = $entry['name'];}
555 if ($old_category != $new_category) {
556 $new_category_ = $new_category;
557 $new_category_ = str_replace(' ', '_', $new_category_);
558 if ($old_category != '') {
559 $StringEcho.= "</table></div></li>";}
560 $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'>";
561 $old_category = $new_category;
562 $DivId++;
564 $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']) .
565 "')\" href='JavaScript:void(0);'>" . xl_form_title($nickname) . "</a></td></tr>";
568 $StringEcho.= '</table></div></li>';
571 if ($StringEcho) {
572 $StringEcho2= '<div style="clear:both"></div>';
573 } else {
574 $StringEcho2="";
577 // This shows Layout Based Form names just like the above.
579 if ($encounterLocked === false) {
580 $lres = sqlStatement("SELECT * FROM list_options " .
581 "WHERE list_id = 'lbfnames' AND activity = 1 ORDER BY seq, title");
582 if (sqlNumRows($lres)) {
583 if (!$StringEcho) {
584 $StringEcho= '<ul id="sddm">';
586 $StringEcho.= "<li class=\"encounter-form-category-li\"><a href='JavaScript:void(0);' onClick=\"mopen('lbf');\" >" .
587 xl('Layout Based') . "</a><div id='lbf' ><table border='0' cellspacing='0' cellpadding='0'>";
588 while ($lrow = sqlFetchArray($lres)) {
589 $option_id = $lrow['option_id']; // should start with LBF
590 $title = $lrow['title'];
591 // Check ACO attribute, if any, of this LBF.
592 $jobj = json_decode($lrow['notes'], true);
593 if (!empty($jobj['aco'])) {
594 $tmp = explode('|', $jobj['aco']);
595 if (!acl_check($tmp[0], $tmp[1], '', 'write') && !acl_check($tmp[0], $tmp[1], '', 'addonly')) {
596 continue;
599 $StringEcho .= "<tr><td style='border-top: 1px solid #000000;padding:0px;'><a href='" .
600 $rootdir . '/patient_file/encounter/load_form.php?formname=' .
601 urlencode($option_id) . "' >" . xl_form_title($title) . "</a></td></tr>";
606 <!-- DISPLAYING HOOKS STARTS HERE -->
607 <?php
608 $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
609 obj_name=enabled_hooks AND ms.mod_id=msh.mod_id LEFT OUTER JOIN modules AS m ON m.mod_id=ms.mod_id
610 WHERE fld_type=3 AND mod_active=1 AND sql_run=1 AND attached_to='encounter' ORDER BY mod_id");
611 $DivId = 'mod_installer';
612 if (sqlNumRows($module_query)) {
613 $jid = 0;
614 $modid = '';
615 while ($modulerow = sqlFetchArray($module_query)) {
616 $DivId = 'mod_'.$modulerow['mod_id'];
617 $new_category = $modulerow['mod_ui_name'];
618 $modulePath = "";
619 $added = "";
620 if ($modulerow['type'] == 0) {
621 $modulePath = $GLOBALS['customModDir'];
622 $added = "";
623 } else {
624 $added = "index";
625 $modulePath = $GLOBALS['zendModDir'];
627 $relative_link = "../../modules/".$modulePath."/".$modulerow['path'];
628 $nickname = $modulerow['menu_name'] ? $modulerow['menu_name'] : 'Noname';
629 if ($jid==0 || ($modid!=$modulerow['mod_id'])) {
630 if ($modid!='') {
631 $StringEcho.= '</table></div></li>';
633 $StringEcho.= "<li><a href='JavaScript:void(0);' onClick=\"mopen('$DivId');\" >$new_category</a><div id='$DivId' ><table border='0' cellspacing='0' cellpadding='0'>";
635 $jid++;
636 $modid = $modulerow['mod_id'];
637 $StringEcho.= "<tr><td style='border-top: 1px solid #000000;padding:0px;'><a onclick=\"openNewForm('$relative_link')\" href='JavaScript:void(0);'>" . xl_form_title($nickname) . "</a></td></tr>";
641 <!-- DISPLAYING HOOKS ENDS HERE -->
642 <?php
643 if ($StringEcho) {
644 $StringEcho.= "</table></div></li></ul>".$StringEcho2;
647 <table cellspacing="0" cellpadding="0" align="center">
648 <tr>
649 <td valign="top"><?php echo $StringEcho; ?></td>
650 </tr>
651 </table>
652 </dl>
653 <!-- Form menu stop -->
654 <!-- *************** -->
656 <div id="encounter_forms">
658 <?php
659 $dateres = getEncounterDateByEncounter($encounter);
660 $encounter_date = date("Y-m-d", strtotime($dateres["date"]));
661 $providerIDres = getProviderIdOfEncounter($encounter);
662 $providerNameRes = getProviderName($providerIDres);
665 <div class='encounter-summary-container'>
666 <div class='encounter-summary-column'>
667 <div>
668 <?php
669 $pass_sens_squad = true;
671 //fetch acl for category of given encounter
672 $pc_catid = fetchCategoryIdByEncounter($encounter);
673 $postCalendarCategoryACO = fetchPostCalendarCategoryACO($pc_catid);
674 if ($postCalendarCategoryACO) {
675 $postCalendarCategoryACO = explode('|', $postCalendarCategoryACO);
676 $authPostCalendarCategory = acl_check($postCalendarCategoryACO[0], $postCalendarCategoryACO[1]);
677 $authPostCalendarCategoryWrite = acl_check($postCalendarCategoryACO[0], $postCalendarCategoryACO[1], '', 'write');
678 } else { // if no aco is set for category
679 $authPostCalendarCategory = true;
680 $authPostCalendarCategoryWrite = true;
683 if ($attendant_type == 'pid' && is_numeric($pid)) {
684 echo '<span class="title">' . oeFormatShortDate($encounter_date) . " " . xlt("Encounter") . '</span>';
686 // Check for no access to the patient's squad.
687 $result = getPatientData($pid, "fname,lname,squad");
688 echo htmlspecialchars(xl('for', '', ' ', ' ') . $result['fname'] . " " . $result['lname']);
689 if ($result['squad'] && ! acl_check('squads', $result['squad'])) {
690 $pass_sens_squad = false;
693 // Check for no access to the encounter's sensitivity level.
694 $result = sqlQuery("SELECT sensitivity FROM form_encounter WHERE " .
695 "pid = '$pid' AND encounter = '$encounter' LIMIT 1");
696 if (($result['sensitivity'] && !acl_check('sensitivities', $result['sensitivity'])) || !$authPostCalendarCategory) {
697 $pass_sens_squad = false;
699 // for therapy group
700 } else {
701 echo '<span class="title">' . oeFormatShortDate($encounter_date) . " " . xlt("Group Encounter") . '</span>';
702 // Check for no access to the patient's squad.
703 $result = getGroup($groupId);
704 echo htmlspecialchars(xl('for ', '', ' ', ' ') . $result['group_name']);
705 if ($result['squad'] && ! acl_check('squads', $result['squad'])) {
706 $pass_sens_squad = false;
708 // Check for no access to the encounter's sensitivity level.
709 $result = sqlQuery("SELECT sensitivity FROM form_groups_encounter WHERE " .
710 "group_id = ? AND encounter = ? LIMIT 1", array($groupId, $encounter));
711 if (($result['sensitivity'] && !acl_check('sensitivities', $result['sensitivity'])) || !$authPostCalendarCategory) {
712 $pass_sens_squad = false;
716 </div>
717 <div style='margin-top:8px;'>
718 <?php
719 // ESign for entire encounter
720 $esign = $esignApi->createEncounterESign($encounter);
721 if ($esign->isButtonViewable()) {
722 echo $esign->buttonHtml();
725 <?php if (acl_check('admin', 'super')) { ?>
726 <a href='toggledivs(this.id,this.id);' class='css_button' onclick='return deleteme()'><span><?php echo xl('Delete') ?></span></a>
727 <?php } ?>
728 &nbsp;&nbsp;&nbsp;<a href="#" onClick='expandcollapse("expand");' style="font-size:80%;"><?php xl('Expand All', 'e'); ?></a>
729 &nbsp;&nbsp;&nbsp;<a style="font-size:80%;" href="#" onClick='expandcollapse("collapse");'><?php xl('Collapse All', 'e'); ?></a>
730 </div>
731 </div>
733 <div class='encounter-summary-column'>
734 <?php if ($esign->isLogViewable()) {
735 $esign->renderLog();
736 } ?>
737 </div>
739 <div class='encounter-summary-column'>
740 <?php if ($GLOBALS['enable_amc_prompting']) { ?>
741 <div style='float:right;margin-right:25px;border-style:solid;border-width:1px;'>
742 <div style='float:left;margin:5px 5px 5px 5px;'>
743 <table>
744 <tr>
745 <td>
746 <?php // Display the education resource checkbox (AMC prompting)
747 $itemAMC = amcCollect("patient_edu_amc", $pid, 'form_encounter', $encounter);
749 <?php if (!(empty($itemAMC))) { ?>
750 <input type="checkbox" id="prov_edu_res" checked>
751 <?php } else { ?>
752 <input type="checkbox" id="prov_edu_res">
753 <?php } ?>
754 </td>
755 <td>
756 <span class="text"><?php echo xl('Provided Education Resource(s)?') ?></span>
757 </td>
758 </tr>
759 <tr>
760 <td>
761 <?php // Display the Provided Clinical Summary checkbox (AMC prompting)
762 $itemAMC = amcCollect("provide_sum_pat_amc", $pid, 'form_encounter', $encounter);
764 <?php if (!(empty($itemAMC))) { ?>
765 <input type="checkbox" id="provide_sum_pat_flag" checked>
766 <?php } else { ?>
767 <input type="checkbox" id="provide_sum_pat_flag">
768 <?php } ?>
769 </td>
770 <td>
771 <span class="text"><?php echo xl('Provided Clinical Summary?') ?></span>
772 </td>
773 </tr>
774 <?php // Display the medication reconciliation checkboxes (AMC prompting)
775 $itemAMC = amcCollect("med_reconc_amc", $pid, 'form_encounter', $encounter);
777 <?php if (!(empty($itemAMC))) { ?>
778 <tr>
779 <td>
780 <input type="checkbox" id="trans_trand_care" checked>
781 </td>
782 <td>
783 <span class="text"><?php echo xl('Transition/Transfer of Care?') ?></span>
784 </td>
785 </tr>
786 </table>
787 <table style="margin-left:2em;">
788 <tr>
789 <td>
790 <?php if (!(empty($itemAMC['date_completed']))) { ?>
791 <input type="checkbox" id="med_reconc_perf" checked>
792 <?php } else { ?>
793 <input type="checkbox" id="med_reconc_perf">
794 <?php } ?>
795 </td>
796 <td>
797 <span class="text"><?php echo xl('Medication Reconciliation Performed?') ?></span>
798 </td>
799 </tr>
800 <tr>
801 <td>
802 <?php if (!(empty($itemAMC['soc_provided']))) { ?>
803 <input type="checkbox" id="soc_provided" checked>
804 <?php } else { ?>
805 <input type="checkbox" id="soc_provided">
806 <?php } ?>
807 </td>
808 <td>
809 <span class="text"><?php echo xl('Summary Of Care Provided?') ?></span>
810 </td>
811 </tr>
812 </table>
813 <?php } else { ?>
814 <tr>
815 <td>
816 <input type="checkbox" id="trans_trand_care">
817 </td>
818 <td>
819 <span class="text"><?php echo xl('Transition/Transfer of Care?') ?></span>
820 </td>
821 </tr>
822 </table>
823 <table style="margin-left:2em;">
824 <tr>
825 <td>
826 <input type="checkbox" id="med_reconc_perf" DISABLED>
827 </td>
828 <td>
829 <span class="text"><?php echo xl('Medication Reconciliation Performed?') ?></span>
830 </td>
831 </tr>
832 <tr>
833 <td>
834 <input type="checkbox" id="soc_provided" DISABLED>
835 </td>
836 <td>
837 <span class="text"><?php echo xl('Summary of Care Provided?') ?></span>
838 </td>
839 </tr>
840 </table>
841 <?php } ?>
842 </div>
843 </div>
844 <?php } ?>
845 </div>
847 </div>
849 <!-- Get the documents tagged to this encounter and display the links and notes as the tooltip -->
850 <?php
851 if ($attendant_type == 'pid') {
852 $docs_list = getDocumentsByEncounter($pid, $_SESSION['encounter']);
853 } else {
854 // already doesn't exist document for therapy groups
855 $docs_list = array();
857 if (count($docs_list) > 0) {
859 <div class='enc_docs'>
860 <span class="bold"><?php echo xlt("Document(s)"); ?>:</span>
861 <?php
862 $doc = new C_Document();
863 foreach ($docs_list as $doc_iter) {
864 $doc_url = $doc->_tpl_vars[CURRENT_ACTION]. "&view&patient_id=".attr($pid)."&document_id=" . attr($doc_iter[id]) . "&";
865 // Get notes for this document.
866 $queryString = "SELECT GROUP_CONCAT(note ORDER BY date DESC SEPARATOR '|') AS docNotes, GROUP_CONCAT(date ORDER BY date DESC SEPARATOR '|') AS docDates
867 FROM notes WHERE foreign_id = ? GROUP BY foreign_id";
868 $noteData = sqlQuery($queryString, array($doc_iter[id]));
869 $note = '';
870 if ($noteData) {
871 $notes = array();
872 $notes = explode("|", $noteData['docNotes']);
873 $dates = explode("|", $noteData['docDates']);
874 for ($i = 0; $i < count($notes); $i++) {
875 $note .= oeFormatShortDate(date('Y-m-d', strtotime($dates[$i]))) . " : " . $notes[$i] . "\n";
879 <br>
880 <a href="<?php echo $doc_url;?>" style="font-size:small;" onsubmit="return top.restoreSession()"><?php echo oeFormatShortDate($doc_iter[docdate]) . ": " . text(basename($doc_iter[url]));?></a>
881 <?php if ($note != '') {?>
882 <a href="javascript:void(0);" title="<?php echo attr($note);?>"><img src="../../../images/info.png"/></a>
883 <?php }?>
884 <?php } ?>
885 </div>
886 <?php } ?>
887 <br/>
889 <?php
891 if (($pass_sens_squad) && ($result = getFormByEncounter($attendant_id, $encounter, "id, date, form_id, form_name, formdir, user, deleted"))) {
892 echo "<table width='100%' id='partable'>";
893 $divnos=1;
894 foreach ($result as $iter) {
895 $formdir = $iter['formdir'];
897 // skip forms whose 'deleted' flag is set to 1
898 if ($iter['deleted'] == 1) {
899 continue;
902 $aco_spec = false;
904 if (substr($formdir, 0, 3) == 'LBF') {
905 // Skip LBF forms that we are not authorized to see.
906 $lrow = sqlQuery(
907 "SELECT * FROM list_options WHERE " .
908 "list_id = 'lbfnames' AND option_id = ? AND activity = 1",
909 array($formdir)
911 if (!empty($lrow)) {
912 $jobj = json_decode($lrow['notes'], true);
913 if (!empty($jobj['aco'])) {
914 $aco_spec = explode('|', $jobj['aco']);
915 if (!acl_check($aco_spec[0], $aco_spec[1])) {
916 continue;
920 } else {
921 // Skip non-LBF forms that we are not authorized to see.
922 $tmp = getRegistryEntryByDirectory($formdir, 'aco_spec');
923 if (!empty($tmp['aco_spec'])) {
924 $aco_spec = explode('|', $tmp['aco_spec']);
925 if (!acl_check($aco_spec[0], $aco_spec[1])) {
926 continue;
931 // $form_info = getFormInfoById($iter['id']);
932 if (strtolower(substr($iter['form_name'], 0, 5)) == 'camos') {
933 //CAMOS generates links from report.php and these links should
934 //be clickable without causing view.php to come up unexpectedly.
935 //I feel that the JQuery code in this file leading to a click
936 //on the report.php content to bring up view.php steps on a
937 //form's autonomy to generate it's own html content in it's report
938 //but until any other form has a problem with this, I will just
939 //make an exception here for CAMOS and allow it to carry out this
940 //functionality for all other forms. --Mark
941 echo '<tr title="' . xl('Edit form') . '" '.
942 'id="'.$formdir.'~'.$iter['form_id'].'">';
943 } else {
944 echo '<tr title="' . xl('Edit form') . '" '.
945 'id="'.$formdir.'~'.$iter['form_id'].'" class="text onerow">';
948 $acl_groups = acl_check("groups", "glog", false, 'write') ? true : false;
949 $user = getNameFromUsername($iter['user']);
951 $form_name = ($formdir == 'newpatient') ? xl('Patient Encounter') : xl_form_title($iter['form_name']);
953 // Create the ESign instance for this form
954 $esign = $esignApi->createFormESign($iter['id'], $formdir, $encounter);
955 echo "<tr>";
956 echo "<td style='border-bottom:1px solid'>";
957 // a link to edit the form
958 echo "<div class='form_header_controls'>";
960 // If the form is locked, it is no longer editable
961 if ($esign->isLocked()) {
962 echo "<a href=# class='css_button_small form-edit-button-locked' id='form-edit-button-" . attr($formdir) . "-" . attr($iter['id']) . "'><span>" . xlt('Locked') . "</span></a>";
963 } else {
964 if ((!$aco_spec || acl_check($aco_spec[0], $aco_spec[1], '', 'write') and $is_group == 0 and $authPostCalendarCategoryWrite)
965 or (((!$aco_spec || acl_check($aco_spec[0], $aco_spec[1], '', 'write')) and $is_group and acl_check("groups", "glog", false, 'write')) and $authPostCalendarCategoryWrite)) {
966 echo "<a class='css_button_small form-edit-button' id='form-edit-button-".attr($formdir)."-".attr($iter['id']).
967 "' href='$rootdir/patient_file/encounter/view_form.php?" .
968 "formname=" . attr($formdir) . "&id=" . attr($iter['form_id']) .
969 "' onclick='top.restoreSession()'>";
970 echo "<span>" . xlt('Edit') . "</span></a>";
974 if (($esign->isButtonViewable() and $is_group == 0 and $authPostCalendarCategoryWrite) or ($esign->isButtonViewable() and $is_group and acl_check("groups", "glog", false, 'write') and $authPostCalendarCategoryWrite)) {
975 if (!$aco_spec || acl_check($aco_spec[0], $aco_spec[1], '', 'write')) {
976 echo $esign->buttonHtml();
980 if (acl_check('admin', 'super')) {
981 if ($formdir != 'newpatient' && $formdir != 'newGroupEncounter') {
982 // a link to delete the form from the encounter
983 echo "<a target='_parent'" .
984 " href='$rootdir/patient_file/encounter/delete_form.php?" .
985 "formname=" . $formdir .
986 "&id=" . $iter['id'] .
987 "&encounter=". $encounter.
988 "&pid=".$pid.
989 "' class='css_button_small' title='" . xl('Delete this form') . "' onclick='top.restoreSession()'><span>" . xl('Delete') . "</span></a>";
990 } else {
991 ?><a href='javascript:;' class='css_button_small' style='color:gray'><span><?php xl('Delete', 'e'); ?></span></a><?php
995 echo "<div class='form_header'>";
997 // Figure out the correct author (encounter authors are the '$providerNameRes', while other
998 // form authors are the '$user['fname'] . " " . $user['lname']').
999 if ($formdir == 'newpatient') {
1000 $form_author = $providerNameRes;
1001 } else {
1002 $form_author = $user['fname'] . " " . $user['lname'];
1004 echo "<a href='#' onclick='divtoggle(\"spanid_$divnos\",\"divid_$divnos\");' class='small' id='aid_$divnos'><b>$form_name</b> <span class='text'>". xl('by')." ". htmlspecialchars($form_author) . "</span> (<span id=spanid_$divnos class=\"indicator\">" . xl('Collapse') . "</span>)</a></div>";
1006 echo "</td>\n";
1007 echo "</tr>";
1008 echo "<tr>";
1009 echo "<td valign='top' class='formrow'><div class='tab' id='divid_$divnos' style='display:block'>";
1011 // Use the form's report.php for display. Forms with names starting with LBF
1012 // are list-based forms sharing a single collection of code.
1014 if (substr($formdir, 0, 3) == 'LBF') {
1015 include_once($GLOBALS['incdir'] . "/forms/LBF/report.php");
1017 call_user_func("lbf_report", $attendant_id, $encounter, 2, $iter['form_id'], $formdir, true);
1018 } else {
1019 include_once($GLOBALS['incdir'] . "/forms/$formdir/report.php");
1020 call_user_func($formdir . "_report", $attendant_id, $encounter, 2, $iter['form_id']);
1023 if ($esign->isLogViewable()) {
1024 $esign->renderLog();
1027 echo "</div></td></tr>";
1028 $divnos=$divnos+1;
1030 echo "</table>";
1032 if (!$pass_sens_squad) {
1033 echo xlt("Not authorized to view this encounter");
1037 </div> <!-- end large encounter_forms DIV -->
1038 </body>
1039 </html>