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");
20 if (!empty($_REQUEST['review_id'])) {
22 $encounter=sanitizeNumber($_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");
40 <?php
require $GLOBALS['srcdir'] . '/js/xl/dygraphs.js.php'; ?
>
42 <?php
html_header_show();?
>
43 <link href
="<?php echo $GLOBALS['assets_static_relative']; ?>/bootstrap-3-3-4/dist/css/bootstrap.min.css" rel
="stylesheet" />
44 <?php
if ($_SESSION['language_direction'] == 'rtl') { ?
>
45 <link rel
="stylesheet" href
="<?php echo $GLOBALS['assets_static_relative'] ?>/bootstrap-rtl-3-3-4/dist/css/bootstrap-rtl.min.css">
47 <link rel
="stylesheet" href
="<?php echo $css_header;?>" type
="text/css">
48 <link rel
="stylesheet" type
="text/css" href
="<?php echo $GLOBALS['webroot'] ?>/library/ESign/css/esign.css" />
49 <link rel
="stylesheet" href
="<?php echo $GLOBALS['assets_static_relative']; ?>/modified/dygraphs-2-0-0/dygraph.css" type
="text/css"></script
>
51 <!-- supporting javascript code
-->
52 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-3-1-1/index.js"></script
>
53 <script src
="<?php echo $GLOBALS['assets_static_relative']; ?>/bootstrap-3-3-4/dist/js/bootstrap.min.js" type
="text/javascript"></script
>
54 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/dialog.js?v=<?php echo $v_js_includes; ?>"></script
>
55 <script type
="text/javascript" src
="../../../library/textformat.js"></script
>
56 <script type
="text/javascript" src
="../../../library/js/common.js"></script
>
57 <script src
="<?php echo $GLOBALS['webroot'] ?>/library/ESign/js/jquery.esign.js"></script
>
58 <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
>
61 $esignApi = new Api();
64 <?php
// if the track_anything form exists, then include the styling and js functions for graphing
65 if (file_exists(dirname(__FILE__
) . "/../../forms/track_anything/style.css")) { ?
>
66 <script type
="text/javascript" src
="<?php echo $GLOBALS['web_root']?>/interface/forms/track_anything/report.js"></script
>
67 <link rel
="stylesheet" href
="<?php echo $GLOBALS['web_root']?>/interface/forms/track_anything/style.css" type
="text/css">
71 // If the user requested attachment of any orphaned procedure orders, do it.
72 if (!empty($_GET['attachid'])) {
73 $attachid = explode(',', $_GET['attachid']);
74 foreach ($attachid as $aid) {
80 "SELECT COUNT(*) AS count FROM procedure_order WHERE " .
81 "procedure_order_id = ? AND patient_id = ? AND encounter_id = 0 AND activity = 1",
84 if (!empty($tmp['count'])) {
86 "UPDATE procedure_order SET encounter_id = ? WHERE " .
87 "procedure_order_id = ? AND patient_id = ? AND encounter_id = 0 AND activity = 1",
88 array($encounter, $aid, $pid)
90 addForm($encounter, "Procedure Order", $aid, "procedure_order", $pid, $userauthorized);
96 <script type
="text/javascript">
98 jQuery(document
).ready( function($
) {
99 var formConfig
= <?php
echo $esignApi->formConfigToJson(); ?
>;
100 $
(".esign-button-form").esign(
103 afterFormSuccess
: function( response
) {
104 if ( response
.locked
) {
105 var editButtonId
= "form-edit-button-"+response
.formDir+
"-"+response
.formId
;
106 $
("#"+editButtonId
).replaceWith( response
.editButtonHtml
);
109 var logId
= "esign-signature-log-"+response
.formDir+
"-"+response
.formId
;
110 $
.post( formConfig
.logViewAction
, response
, function( html
) {
111 $
("#"+logId
).replaceWith( html
);
117 var encounterConfig
= <?php
echo $esignApi->encounterConfigToJson(); ?
>;
118 $
(".esign-button-encounter").esign(
121 afterFormSuccess
: function( response
) {
122 // If the response indicates a locked encounter, replace all
123 // form edit buttons with a "disabled" button, and "disable" left
124 // nav visit form links
125 if ( response
.locked
) {
126 // Lock the form edit buttons
127 $
(".form-edit-button").replaceWith( response
.editButtonHtml
);
128 // Disable the new-form capabilities in left nav
129 top
.window
.parent
.left_nav
.syncRadios();
130 // Disable the new-form capabilities in top nav of the encounter
131 $
(".encounter-form-category-li").remove();
134 var logId
= "esign-signature-log-encounter-"+response
.encounterId
;
135 $
.post( encounterConfig
.logViewAction
, response
, function( html
) {
136 $
("#"+logId
).replaceWith( html
);
142 $
("#prov_edu_res").click(function() {
143 if ( $
('#prov_edu_res').prop('checked') ) {
149 top
.restoreSession();
150 $
.post( "../../../library/ajax/amc_misc_data.php",
151 { amc_id
: "patient_edu_amc",
154 patient_id
: <?php
echo htmlspecialchars($pid, ENT_NOQUOTES
); ?
>,
155 object_category
: "form_encounter",
156 object_id
: <?php
echo htmlspecialchars($encounter, ENT_NOQUOTES
); ?
>
161 $
("#provide_sum_pat_flag").click(function() {
162 if ( $
('#provide_sum_pat_flag').prop('checked') ) {
168 top
.restoreSession();
169 $
.post( "../../../library/ajax/amc_misc_data.php",
170 { amc_id
: "provide_sum_pat_amc",
173 patient_id
: <?php
echo htmlspecialchars($pid, ENT_NOQUOTES
); ?
>,
174 object_category
: "form_encounter",
175 object_id
: <?php
echo htmlspecialchars($encounter, ENT_NOQUOTES
); ?
>
180 $
("#trans_trand_care").click(function() {
181 if ( $
('#trans_trand_care').prop('checked') ) {
183 // Enable the reconciliation checkbox
184 $
("#med_reconc_perf").removeAttr("disabled");
185 $
("#soc_provided").removeAttr("disabled");
189 //Disable the reconciliation checkbox (also uncheck it if applicable)
190 $
("#med_reconc_perf").attr("disabled", true);
191 $
("#med_reconc_perf").prop("checked",false);
192 $
("#soc_provided").attr("disabled",true);
193 $
("#soc_provided").prop("checked",false);
195 top
.restoreSession();
196 $
.post( "../../../library/ajax/amc_misc_data.php",
197 { amc_id
: "med_reconc_amc",
200 patient_id
: <?php
echo htmlspecialchars($pid, ENT_NOQUOTES
); ?
>,
201 object_category
: "form_encounter",
202 object_id
: <?php
echo htmlspecialchars($encounter, ENT_NOQUOTES
); ?
>
207 $
("#med_reconc_perf").click(function() {
208 if ( $
('#med_reconc_perf').prop('checked') ) {
209 var mode
= "complete";
212 var mode
= "uncomplete";
214 top
.restoreSession();
215 $
.post( "../../../library/ajax/amc_misc_data.php",
216 { amc_id
: "med_reconc_amc",
219 patient_id
: <?php
echo htmlspecialchars($pid, ENT_NOQUOTES
); ?
>,
220 object_category
: "form_encounter",
221 object_id
: <?php
echo htmlspecialchars($encounter, ENT_NOQUOTES
); ?
>
225 $
("#soc_provided").click(function(){
226 if($
('#soc_provided').prop('checked')){
227 var mode
= "soc_provided";
230 var mode
= "no_soc_provided";
232 top
.restoreSession();
233 $
.post( "../../../library/ajax/amc_misc_data.php",
234 { amc_id
: "med_reconc_amc",
237 patient_id
: <?php
echo htmlspecialchars($pid, ENT_NOQUOTES
); ?
>,
238 object_category
: "form_encounter",
239 object_id
: <?php
echo htmlspecialchars($encounter, ENT_NOQUOTES
); ?
>
244 $
(".deleteme").click(function(evt
) { deleteme(); evt
.stopPropogation(); });
247 // If the user was not just asked about orphaned orders, build javascript for that.
248 if (!isset($_GET['attachid'])) {
249 $ares = sqlStatement(
250 "SELECT procedure_order_id, date_ordered " .
251 "FROM procedure_order WHERE " .
252 "patient_id = ? AND encounter_id = 0 AND activity = 1 " .
253 "ORDER BY procedure_order_id",
256 echo " // Ask about attaching orphaned orders to this encounter.\n";
257 echo " var attachid = '';\n";
258 while ($arow = sqlFetchArray($ares)) {
259 $orderid = $arow['procedure_order_id'];
260 $orderdate = $arow['date_ordered'];
261 echo " if (confirm('" . xls('There is a lab order') . " $orderid " .
262 xls('dated') . " $orderdate " .
263 xls('for this patient not yet assigned to any encounter.') . " " .
264 xls('Assign it to this one?') . "')) attachid += '$orderid,';\n";
266 echo " if (attachid) location.href = 'forms.php?attachid=' + attachid;\n";
270 <?php
if ($reviewMode) { ?
>
271 $
("body table:first").hide();
272 $
(".encounter-summary-column").hide();
273 $
(".css_button").hide();
274 $
(".css_button_small").hide();
275 $
(".encounter-summary-column:first").show();
276 $
(".title:first").text("<?php echo xls("Review
"); ?> " + $
(".title:first").text() +
" ( <?php echo addslashes($encounter); ?> )");
280 // Process click on Delete link.
281 function deleteme() {
282 dlgopen('../deleter.php?encounterid=<?php echo $encounter; ?>', '_blank', 500, 200, '', '', {
284 {text
: '<?php echo xla('Done
'); ?>', close
: true, style
: 'primary btn-sm'}
292 // Called by the deleter.php window on a successful delete.
293 function imdeleted(EncounterId
) {
294 top
.window
.parent
.left_nav
.removeOptionSelected(EncounterId
);
295 top
.window
.parent
.left_nav
.clearEncounter();
299 top
.window
.parent
.left_nav
.loadFrame('ens1', window
.parent
.name
, 'patient_file/history/encounters.php');
303 // Called to open the data entry form a specified encounter form instance.
304 function openEncounterForm(formdir
, formname
, formid
) {
305 var url
= '<?php echo "$rootdir/patient_file/encounter/view_form.php?formname=" ?>' +
306 formdir +
'&id=' + formid
;
307 if (formdir
== 'newpatient' ||
!parent
.twAddFrameTab
) {
311 parent
.twAddFrameTab('enctabs', formname
, url
);
316 // Called when an encounter form may changed something that requires a refresh here.
317 function refreshVisitDisplay() {
318 location
.href
= '<?php echo $rootdir; ?>/patient_file/encounter/forms.php';
323 <script language
="javascript">
324 function expandcollapse(atr
) {
325 for (var i
= 1; i
< 15; ++i
) {
326 var mydivid
="divid_" + i
; var myspanid
= "spanid_" + i
;
327 var ele
= document
.getElementById(mydivid
);
328 var text
= document
.getElementById(myspanid
);
330 if (atr
== "expand") {
331 ele
.style
.display
= "block"; text
.innerHTML
= "<?php xl('Collapse', 'e'); ?>";
334 ele
.style
.display
= "none" ; text
.innerHTML
= "<?php xl('Expand', 'e'); ?>";
339 function divtoggle(spanid
, divid
) {
340 var ele
= document
.getElementById(divid
);
341 var text
= document
.getElementById(spanid
);
342 if(ele
.style
.display
== "block") {
343 ele
.style
.display
= "none";
344 text
.innerHTML
= "<?php xl('Expand', 'e'); ?>";
347 ele
.style
.display
= "block";
348 text
.innerHTML
= "<?php xl('Collapse', 'e'); ?>";
353 <style type
="text/css">
364 div
.form_header_controls
{
378 .encounter
-summary
-container
{
383 .encounter
-summary
-column
{
391 <!-- *************** -->
392 <!-- Form menu start
-->
393 <script language
="JavaScript">
395 function openNewForm(sel
, label
) {
396 top
.restoreSession();
397 var FormNameValueArray
= sel
.split('formname=');
398 if (FormNameValueArray
[1] == 'newpatient') {
399 // TBD: Make this work when it's not the first frame.
400 parent
.frames
[0].location
.href
= sel
;
403 parent
.twAddFrameTab('enctabs', label
, sel
);
407 function toggleFrame1(fnum
) {
408 top
.frames
['left_nav'].document
.forms
[0].cb_top
.checked
=false;
409 top
.window
.parent
.left_nav
.toggleFrame(fnum
);
412 <style type
="text/css">
420 <script type
="text/javascript" language
="javascript">
425 var oldddmenuitem
= 0;
431 // cancel close timer
432 //mcancelclosetime();
437 //if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
438 //if(ddmenuitem) ddmenuitem.style.display = 'none';
440 // get new layer and show it
441 oldddmenuitem
= ddmenuitem
;
442 ddmenuitem
= document
.getElementById(id
);
443 if((ddmenuitem
.style
.visibility
== '')||
(ddmenuitem
.style
.visibility
== 'hidden')){
444 if(oldddmenuitem
) oldddmenuitem
.style
.visibility
= 'hidden';
445 if(oldddmenuitem
) oldddmenuitem
.style
.display
= 'none';
446 ddmenuitem
.style
.visibility
= 'visible';
447 ddmenuitem
.style
.display
= 'block';
449 ddmenuitem
.style
.visibility
= 'hidden';
450 ddmenuitem
.style
.display
= 'none';
453 // close showed layer
461 if(ddmenuitem
) ddmenuitem
.style
.visibility
= 'hidden';
462 if(ddmenuitem
) ddmenuitem
.style
.display
= 'none';
465 // close layer when click-out
466 document
.onclick
= mclose
;
467 //=================================================
468 function findPosX(id
)
470 obj
=document
.getElementById(id
);
475 curleft +
= obj
.offsetLeft
;
476 if(!obj
.offsetParent
)
478 obj
= obj
.offsetParent
;
482 PropertyWidth
=document
.getElementById(id
).offsetWidth
;
483 if(PropertyWidth
>curleft
)
485 document
.getElementById(id
).style
.left
=0;
489 function findPosY(obj
)
495 curtop +
= obj
.offsetTop
;
496 if(!obj
.offsetParent
)
498 obj
= obj
.offsetParent
;
507 <body
class="bgcolor2">
509 <?php
//DYNAMIC FORM RETREIVAL
510 include_once("$srcdir/registry.inc");
512 function myGetRegistered($state = "1", $limit = "unlimited", $offset = "0")
514 global $attendant_type;
515 $sql = "SELECT category, nickname, name, state, directory, id, sql_run, " .
516 "unpackaged, date, aco_spec FROM registry WHERE ";
517 // select different forms for groups
518 if ($attendant_type == 'pid') {
519 $sql .= "patient_encounter = 1 AND ";
521 $sql .= "therapy_group_encounter = 1 AND ";
523 $sql .= "state LIKE \"$state\" ORDER BY category, priority, name";
524 if ($limit != "unlimited") {
525 $sql .= " limit $limit, $offset";
527 $res = sqlStatement($sql);
529 for ($iter=0; $row=sqlFetchArray($res); $iter++
) {
538 $reg = myGetRegistered();
543 // To see if the encounter is locked. If it is, no new forms can be created
544 $encounterLocked = false;
545 if ($esignApi->lockEncounters() &&
546 isset($GLOBALS['encounter']) &&
547 !empty($GLOBALS['encounter']) ) {
548 $esign = $esignApi->createEncounterESign($GLOBALS['encounter']);
549 if ($esign->isLocked()) {
550 $encounterLocked = true;
555 $StringEcho= '<ul id="sddm">';
556 if ($encounterLocked === false) {
557 foreach ($reg as $entry) {
558 // Check permission to create forms of this type.
559 $tmp = explode('|', $entry['aco_spec']);
560 if (!empty($tmp[1])) {
561 if (!acl_check($tmp[0], $tmp[1], '', 'write') && !acl_check($tmp[0], $tmp[1], '', 'addonly')) {
565 $new_category = trim($entry['category']);
566 $new_nickname = trim($entry['nickname']);
567 if ($new_category == '') {
568 $new_category = htmlspecialchars(xl('Miscellaneous'), ENT_QUOTES
);
570 $new_category = htmlspecialchars(xl($new_category), ENT_QUOTES
);
572 if ($new_nickname != '') {
573 $nickname = $new_nickname;
575 $nickname = trim($entry['name']);
577 if ($old_category != $new_category) {
578 $new_category_ = $new_category;
579 $new_category_ = str_replace(' ', '_', $new_category_);
580 if ($old_category != '') {
581 $StringEcho .= "</table></div></li>";
583 $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'>";
584 $old_category = $new_category;
587 $StringEcho .= "<tr><td style='border-top: 1px solid #000000;padding:0px;'><a onclick=\"openNewForm('" .
588 $rootdir . "/patient_file/encounter/load_form.php?formname=" . urlencode($entry['directory']) .
589 "', '" . addslashes(xl_form_title($nickname)) . "')\" href='JavaScript:void(0);'>" .
590 text(xl_form_title($nickname)) . "</a></td></tr>";
593 $StringEcho.= '</table></div></li>';
597 $StringEcho2= '<div style="clear:both"></div>';
602 // This shows Layout Based Form names just like the above.
604 if ($encounterLocked === false) {
605 $lres = sqlStatement("SELECT grp_form_id AS option_id, grp_title AS title, grp_aco_spec " .
606 "FROM layout_group_properties WHERE " .
607 "grp_form_id LIKE 'LBF%' AND grp_group_id = '' AND grp_activity = 1 " .
608 "ORDER BY grp_seq, grp_title");
610 if (sqlNumRows($lres)) {
612 $StringEcho= '<ul id="sddm">';
614 $StringEcho.= "<li class=\"encounter-form-category-li\"><a href='JavaScript:void(0);' onClick=\"mopen('lbf');\" >" .
615 xl('Layout Based') . "</a><div id='lbf' ><table border='0' cellspacing='0' cellpadding='0'>";
616 while ($lrow = sqlFetchArray($lres)) {
617 $option_id = $lrow['option_id']; // should start with LBF
618 $title = $lrow['title'];
619 // Check ACO attribute, if any, of this LBF.
620 if (!empty($lrow['grp_aco_spec'])) {
621 $tmp = explode('|', $lrow['grp_aco_spec']);
622 if (!acl_check($tmp[0], $tmp[1], '', 'write') && !acl_check($tmp[0], $tmp[1], '', 'addonly')) {
626 $StringEcho .= "<tr><td style='border-top: 1px solid #000000;padding:0px;'><a onclick=\"openNewForm('" .
627 $rootdir . "/patient_file/encounter/load_form.php?formname=" . urlencode($option_id) .
628 "', '" . addslashes(xl_form_title($title)) . "')\" href='JavaScript:void(0);'>" .
629 text(xl_form_title($title)) . "</a></td></tr>";
634 <!-- DISPLAYING HOOKS STARTS HERE
-->
636 $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
637 obj_name=enabled_hooks AND ms.mod_id=msh.mod_id LEFT OUTER JOIN modules AS m ON m.mod_id=ms.mod_id
638 WHERE fld_type=3 AND mod_active=1 AND sql_run=1 AND attached_to='encounter' ORDER BY mod_id");
639 $DivId = 'mod_installer';
640 if (sqlNumRows($module_query)) {
643 while ($modulerow = sqlFetchArray($module_query)) {
644 $DivId = 'mod_'.$modulerow['mod_id'];
645 $new_category = $modulerow['mod_ui_name'];
648 if ($modulerow['type'] == 0) {
649 $modulePath = $GLOBALS['customModDir'];
653 $modulePath = $GLOBALS['zendModDir'];
655 $relative_link = "../../modules/".$modulePath."/".$modulerow['path'];
656 $nickname = $modulerow['menu_name'] ?
$modulerow['menu_name'] : 'Noname';
657 if ($jid==0 ||
($modid!=$modulerow['mod_id'])) {
659 $StringEcho.= '</table></div></li>';
661 $StringEcho.= "<li><a href='JavaScript:void(0);' onClick=\"mopen('$DivId');\" >$new_category</a><div id='$DivId' ><table border='0' cellspacing='0' cellpadding='0'>";
664 $modid = $modulerow['mod_id'];
665 $StringEcho.= "<tr><td style='border-top: 1px solid #000000;padding:0px;'><a onclick=" .
666 "\"openNewForm('$relative_link', '" . addslashes(xl_form_title($nickname)) . "')\" " .
667 "href='JavaScript:void(0);'>" . xl_form_title($nickname) . "</a></td></tr>";
671 <!-- DISPLAYING HOOKS ENDS HERE
-->
674 $StringEcho.= "</table></div></li></ul>".$StringEcho2;
677 <table cellspacing
="0" cellpadding
="0" align
="center">
679 <td valign
="top"><?php
echo $StringEcho; ?
></td
>
683 <!-- Form menu stop
-->
684 <!-- *************** -->
686 <div id
="encounter_forms">
689 $dateres = getEncounterDateByEncounter($encounter);
690 $encounter_date = date("Y-m-d", strtotime($dateres["date"]));
691 $providerIDres = getProviderIdOfEncounter($encounter);
692 $providerNameRes = getProviderName($providerIDres);
695 <div
class='encounter-summary-container'>
696 <div
class='encounter-summary-column'>
699 $pass_sens_squad = true;
701 //fetch acl for category of given encounter
702 $pc_catid = fetchCategoryIdByEncounter($encounter);
703 $postCalendarCategoryACO = fetchPostCalendarCategoryACO($pc_catid);
704 if ($postCalendarCategoryACO) {
705 $postCalendarCategoryACO = explode('|', $postCalendarCategoryACO);
706 $authPostCalendarCategory = acl_check($postCalendarCategoryACO[0], $postCalendarCategoryACO[1]);
707 $authPostCalendarCategoryWrite = acl_check($postCalendarCategoryACO[0], $postCalendarCategoryACO[1], '', 'write');
708 } else { // if no aco is set for category
709 $authPostCalendarCategory = true;
710 $authPostCalendarCategoryWrite = true;
713 if ($attendant_type == 'pid' && is_numeric($pid)) {
714 echo '<span class="title">' . text(oeFormatShortDate($encounter_date)) . " " . xlt("Encounter") . '</span>';
716 // Check for no access to the patient's squad.
717 $result = getPatientData($pid, "fname,lname,squad");
718 echo htmlspecialchars(xl('for', '', ' ', ' ') . $result['fname'] . " " . $result['lname']);
719 if ($result['squad'] && ! acl_check('squads', $result['squad'])) {
720 $pass_sens_squad = false;
723 // Check for no access to the encounter's sensitivity level.
724 $result = sqlQuery("SELECT sensitivity FROM form_encounter WHERE " .
725 "pid = '$pid' AND encounter = '$encounter' LIMIT 1");
726 if (($result['sensitivity'] && !acl_check('sensitivities', $result['sensitivity'])) ||
!$authPostCalendarCategory) {
727 $pass_sens_squad = false;
731 echo '<span class="title">' . text(oeFormatShortDate($encounter_date)) . " " . xlt("Group Encounter") . '</span>';
732 // Check for no access to the patient's squad.
733 $result = getGroup($groupId);
734 echo htmlspecialchars(xl('for ', '', ' ', ' ') . $result['group_name']);
735 if ($result['squad'] && ! acl_check('squads', $result['squad'])) {
736 $pass_sens_squad = false;
738 // Check for no access to the encounter's sensitivity level.
739 $result = sqlQuery("SELECT sensitivity FROM form_groups_encounter WHERE " .
740 "group_id = ? AND encounter = ? LIMIT 1", array($groupId, $encounter));
741 if (($result['sensitivity'] && !acl_check('sensitivities', $result['sensitivity'])) ||
!$authPostCalendarCategory) {
742 $pass_sens_squad = false;
747 <div style
='margin-top:8px;'>
749 // ESign for entire encounter
750 $esign = $esignApi->createEncounterESign($encounter);
751 if ($esign->isButtonViewable()) {
752 echo $esign->buttonHtml();
755 <?php
if (acl_check('admin', 'super')) { ?
>
756 <a href
='#' class='css_button' onclick
='return deleteme()'><span
><?php
echo xl('Delete') ?
></span
></a
>
758  
; 
; 
;<a href
="#" onClick
='expandcollapse("expand");' style
="font-size:80%;"><?php
xl('Expand All', 'e'); ?
></a
>
759  
; 
; 
;<a style
="font-size:80%;" href
="#" onClick
='expandcollapse("collapse");'><?php
xl('Collapse All', 'e'); ?
></a
>
763 <div
class='encounter-summary-column'>
764 <?php
if ($esign->isLogViewable()) {
769 <div
class='encounter-summary-column'>
770 <?php
if ($GLOBALS['enable_amc_prompting']) { ?
>
771 <div style
='float:right;margin-right:25px;border-style:solid;border-width:1px;'>
772 <div style
='float:left;margin:5px 5px 5px 5px;'>
776 <?php
// Display the education resource checkbox (AMC prompting)
777 $itemAMC = amcCollect("patient_edu_amc", $pid, 'form_encounter', $encounter);
779 <?php
if (!(empty($itemAMC))) { ?
>
780 <input type
="checkbox" id
="prov_edu_res" checked
>
782 <input type
="checkbox" id
="prov_edu_res">
786 <span
class="text"><?php
echo xl('Provided Education Resource(s)?') ?
></span
>
791 <?php
// Display the Provided Clinical Summary checkbox (AMC prompting)
792 $itemAMC = amcCollect("provide_sum_pat_amc", $pid, 'form_encounter', $encounter);
794 <?php
if (!(empty($itemAMC))) { ?
>
795 <input type
="checkbox" id
="provide_sum_pat_flag" checked
>
797 <input type
="checkbox" id
="provide_sum_pat_flag">
801 <span
class="text"><?php
echo xl('Provided Clinical Summary?') ?
></span
>
804 <?php
// Display the medication reconciliation checkboxes (AMC prompting)
805 $itemAMC = amcCollect("med_reconc_amc", $pid, 'form_encounter', $encounter);
807 <?php
if (!(empty($itemAMC))) { ?
>
810 <input type
="checkbox" id
="trans_trand_care" checked
>
813 <span
class="text"><?php
echo xl('Transition/Transfer of Care?') ?
></span
>
817 <table style
="margin-left:2em;">
820 <?php
if (!(empty($itemAMC['date_completed']))) { ?
>
821 <input type
="checkbox" id
="med_reconc_perf" checked
>
823 <input type
="checkbox" id
="med_reconc_perf">
827 <span
class="text"><?php
echo xl('Medication Reconciliation Performed?') ?
></span
>
832 <?php
if (!(empty($itemAMC['soc_provided']))) { ?
>
833 <input type
="checkbox" id
="soc_provided" checked
>
835 <input type
="checkbox" id
="soc_provided">
839 <span
class="text"><?php
echo xl('Summary Of Care Provided?') ?
></span
>
846 <input type
="checkbox" id
="trans_trand_care">
849 <span
class="text"><?php
echo xl('Transition/Transfer of Care?') ?
></span
>
853 <table style
="margin-left:2em;">
856 <input type
="checkbox" id
="med_reconc_perf" DISABLED
>
859 <span
class="text"><?php
echo xl('Medication Reconciliation Performed?') ?
></span
>
864 <input type
="checkbox" id
="soc_provided" DISABLED
>
867 <span
class="text"><?php
echo xl('Summary of Care Provided?') ?
></span
>
879 <!-- Get the documents tagged to this encounter
and display the links
and notes
as the tooltip
-->
881 if ($attendant_type == 'pid') {
882 $docs_list = getDocumentsByEncounter($pid, $_SESSION['encounter']);
884 // already doesn't exist document for therapy groups
885 $docs_list = array();
887 if (count($docs_list) > 0) {
889 <div
class='enc_docs'>
890 <span
class="bold"><?php
echo xlt("Document(s)"); ?
>:</span
>
892 $doc = new C_Document();
893 foreach ($docs_list as $doc_iter) {
894 $doc_url = $doc->_tpl_vars
[CURRENT_ACTION
]. "&view&patient_id=".attr($pid)."&document_id=" . attr($doc_iter[id
]) . "&";
895 // Get notes for this document.
896 $queryString = "SELECT GROUP_CONCAT(note ORDER BY date DESC SEPARATOR '|') AS docNotes, GROUP_CONCAT(date ORDER BY date DESC SEPARATOR '|') AS docDates
897 FROM notes WHERE foreign_id = ? GROUP BY foreign_id";
898 $noteData = sqlQuery($queryString, array($doc_iter[id
]));
902 $notes = explode("|", $noteData['docNotes']);
903 $dates = explode("|", $noteData['docDates']);
904 for ($i = 0; $i < count($notes); $i++
) {
905 $note .= oeFormatShortDate(date('Y-m-d', strtotime($dates[$i]))) . " : " . $notes[$i] . "\n";
910 <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
>
911 <?php
if ($note != '') {?
>
912 <a href
="javascript:void(0);" title
="<?php echo attr($note);?>"><img src
="../../../images/info.png"/></a
>
920 if ($pass_sens_squad &&
921 ($result = getFormByEncounter(
924 "id, date, form_id, form_name, formdir, user, deleted",
926 "FIND_IN_SET(formdir,'newpatient') DESC, form_name, date DESC"
928 echo "<table width='100%' id='partable'>";
930 foreach ($result as $iter) {
931 $formdir = $iter['formdir'];
933 // skip forms whose 'deleted' flag is set to 1
934 if ($iter['deleted'] == 1) {
940 if (substr($formdir, 0, 3) == 'LBF') {
941 // Skip LBF forms that we are not authorized to see.
943 "SELECT grp_aco_spec " .
944 "FROM layout_group_properties WHERE " .
945 "grp_form_id = ? AND grp_group_id = '' AND grp_activity = 1",
949 if (!empty($lrow['grp_aco_spec'])) {
950 $aco_spec = explode('|', $lrow['grp_aco_spec']);
951 if (!acl_check($aco_spec[0], $aco_spec[1])) {
957 // Skip non-LBF forms that we are not authorized to see.
958 $tmp = getRegistryEntryByDirectory($formdir, 'aco_spec');
959 if (!empty($tmp['aco_spec'])) {
960 $aco_spec = explode('|', $tmp['aco_spec']);
961 if (!acl_check($aco_spec[0], $aco_spec[1])) {
967 // $form_info = getFormInfoById($iter['id']);
968 if (strtolower(substr($iter['form_name'], 0, 5)) == 'camos') {
969 //CAMOS generates links from report.php and these links should
970 //be clickable without causing view.php to come up unexpectedly.
971 //I feel that the JQuery code in this file leading to a click
972 //on the report.php content to bring up view.php steps on a
973 //form's autonomy to generate it's own html content in it's report
974 //but until any other form has a problem with this, I will just
975 //make an exception here for CAMOS and allow it to carry out this
976 //functionality for all other forms. --Mark
977 echo '<tr title="' . xl('Edit form') . '" '.
978 'id="'.$formdir.'~'.$iter['form_id'].'">';
980 echo '<tr id="' . $formdir . '~' . $iter['form_id'] . '" class="text onerow">';
983 $acl_groups = acl_check("groups", "glog", false, 'write') ?
true : false;
984 $user = getNameFromUsername($iter['user']);
986 $form_name = ($formdir == 'newpatient') ?
xl('Visit Summary') : xl_form_title($iter['form_name']);
988 // Create the ESign instance for this form
989 $esign = $esignApi->createFormESign($iter['id'], $formdir, $encounter);
991 // echo "<tr>"; // Removed as bug fix.
993 echo "<td style='border-bottom:1px solid'>";
995 // Figure out the correct author (encounter authors are the '$providerNameRes', while other
996 // form authors are the '$user['fname'] . " " . $user['lname']').
997 if ($formdir == 'newpatient') {
998 $form_author = $providerNameRes;
1000 $form_author = $user['fname'] . " " . $user['lname'];
1002 echo "<div class='form_header'>";
1003 echo "<a href='#' onclick='divtoggle(\"spanid_$divnos\",\"divid_$divnos\");' class='small' id='aid_$divnos'>" .
1004 "<div class='formname'>" . text($form_name) . "</div> " .
1005 xlt('by') . " " . text($form_author) . " " .
1006 "(<span id=spanid_$divnos class=\"indicator\">" . ($divnos == 1 ?
xlt('Collapse') : xlt('Expand')) . "</span>)</a>";
1009 // a link to edit the form
1010 echo "<div class='form_header_controls'>";
1012 // If the form is locked, it is no longer editable
1013 if ($esign->isLocked()) {
1014 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>";
1016 if ((!$aco_spec ||
acl_check($aco_spec[0], $aco_spec[1], '', 'write') and $is_group == 0 and $authPostCalendarCategoryWrite)
1017 or (((!$aco_spec ||
acl_check($aco_spec[0], $aco_spec[1], '', 'write')) and $is_group and acl_check("groups", "glog", false, 'write')) and $authPostCalendarCategoryWrite)) {
1018 echo "<a class='css_button_small form-edit-button' " .
1019 "id='form-edit-button-" . attr($formdir) . "-" . attr($iter['id']) . "' " .
1021 "title='" . xla('Edit this form') . "' " .
1022 "onclick=\"return openEncounterForm('" . attr($formdir) . "', '" .
1023 attr($form_name) . "', '" . attr($iter['form_id']) . "')\">";
1024 echo "<span>" . xlt('Edit') . "</span></a>";
1028 if (($esign->isButtonViewable() and $is_group == 0 and $authPostCalendarCategoryWrite) or ($esign->isButtonViewable() and $is_group and acl_check("groups", "glog", false, 'write') and $authPostCalendarCategoryWrite)) {
1029 if (!$aco_spec ||
acl_check($aco_spec[0], $aco_spec[1], '', 'write')) {
1030 echo $esign->buttonHtml();
1034 if (substr($formdir, 0, 3) == 'LBF') {
1035 // A link for a nice printout of the LBF
1036 echo "<a target='_blank' " .
1037 "href='$rootdir/forms/LBF/printable.php?" .
1038 "formname=" . urlencode($formdir) .
1039 "&formid=" . urlencode($iter['form_id']) .
1040 "&visitid=" . urlencode($encounter) .
1041 "&patientid=" . urlencode($pid) .
1042 "' class='css_button_small' title='" . xl('Print this form') .
1043 "' onclick='top.restoreSession()'><span>" . xlt('Print') . "</span></a>";
1046 if (acl_check('admin', 'super')) {
1047 if ($formdir != 'newpatient' && $formdir != 'newGroupEncounter') {
1048 // a link to delete the form from the encounter
1049 echo "<a href='$rootdir/patient_file/encounter/delete_form.php?" .
1050 "formname=" . $formdir .
1051 "&id=" . $iter['id'] .
1052 "&encounter=". $encounter.
1054 "' class='css_button_small' title='" . xl('Delete this form') . "' onclick='top.restoreSession()'><span>" . xl('Delete') . "</span></a>";
1056 ?
><a href
='javascript:;' class='css_button_small' style
='color:gray'><span
><?php
xl('Delete', 'e'); ?
></span
></a
><?php
1059 echo "</div>\n"; // Added as bug fix.
1064 echo "<td valign='top' class='formrow'><div class='tab' id='divid_$divnos' ";
1065 echo "style='display:" . ($divnos == 1 ?
'block' : 'none') . "'>";
1067 // Use the form's report.php for display. Forms with names starting with LBF
1068 // are list-based forms sharing a single collection of code.
1070 if (substr($formdir, 0, 3) == 'LBF') {
1071 include_once($GLOBALS['incdir'] . "/forms/LBF/report.php");
1073 call_user_func("lbf_report", $attendant_id, $encounter, 2, $iter['form_id'], $formdir, true);
1075 include_once($GLOBALS['incdir'] . "/forms/$formdir/report.php");
1076 call_user_func($formdir . "_report", $attendant_id, $encounter, 2, $iter['form_id']);
1079 if ($esign->isLogViewable()) {
1080 $esign->renderLog();
1083 echo "</div></td></tr>";
1088 if (!$pass_sens_squad) {
1089 echo xlt("Not authorized to view this encounter");
1093 </div
> <!-- end large encounter_forms DIV
-->