6 * @link http://www.open-emr.org
7 * @author Brady Miller <brady.g.miller@gmail.com>
8 * @copyright Copyright (c) 2018 Brady Miller <brady.g.miller@gmail.com>
9 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
13 require_once("../../globals.php");
14 require_once("$srcdir/encounter.inc");
15 require_once("$srcdir/group.inc");
16 require_once("$srcdir/calendar.inc");
17 require_once("$srcdir/acl.inc");
18 require_once("$srcdir/patient.inc");
19 require_once("$srcdir/amc.php");
20 require_once $GLOBALS['srcdir'].'/ESign/Api.php';
21 require_once("$srcdir/../controllers/C_Document.class.php");
24 use OpenEMR\Core\Header
;
27 if (!empty($_REQUEST['review_id'])) {
29 $encounter=sanitizeNumber($_REQUEST['review_id']);
32 $is_group = ($attendant_type == 'gid') ?
true : false;
33 if ($attendant_type == 'gid') {
34 $groupId = $therapy_group;
36 $attendant_id = $attendant_type == 'pid' ?
$pid : $therapy_group;
37 if ($is_group && !acl_check("groups", "glog", false, array('view','write'))) {
38 echo xlt("access not allowed");
47 <?php
require $GLOBALS['srcdir'] . '/js/xl/dygraphs.js.php'; ?
>
49 <?php Header
::setupHeader(['common','esign','dygraphs']); ?
>
52 $esignApi = new Api();
55 <?php
// if the track_anything form exists, then include the styling and js functions (and js variable) for graphing
56 if (file_exists(dirname(__FILE__
) . "/../../forms/track_anything/style.css")) { ?
>
57 <script type
="text/javascript">
58 var csrf_token_js
= <?php
echo js_escape(collectCsrfToken()); ?
>;
60 <script type
="text/javascript" src
="<?php echo $GLOBALS['web_root']?>/interface/forms/track_anything/report.js"></script
>
61 <link rel
="stylesheet" href
="<?php echo $GLOBALS['web_root']?>/interface/forms/track_anything/style.css" type
="text/css">
65 // If the user requested attachment of any orphaned procedure orders, do it.
66 if (!empty($_GET['attachid'])) {
67 $attachid = explode(',', $_GET['attachid']);
68 foreach ($attachid as $aid) {
74 "SELECT COUNT(*) AS count FROM procedure_order WHERE " .
75 "procedure_order_id = ? AND patient_id = ? AND encounter_id = 0 AND activity = 1",
78 if (!empty($tmp['count'])) {
80 "UPDATE procedure_order SET encounter_id = ? WHERE " .
81 "procedure_order_id = ? AND patient_id = ? AND encounter_id = 0 AND activity = 1",
82 array($encounter, $aid, $pid)
84 addForm($encounter, "Procedure Order", $aid, "procedure_order", $pid, $userauthorized);
90 <script type
="text/javascript">
92 jQuery(document
).ready( function($
) {
93 var formConfig
= <?php
echo $esignApi->formConfigToJson(); ?
>;
94 $
(".esign-button-form").esign(
97 afterFormSuccess
: function( response
) {
98 if ( response
.locked
) {
99 var editButtonId
= "form-edit-button-"+response
.formDir+
"-"+response
.formId
;
100 $
("#"+editButtonId
).replaceWith( response
.editButtonHtml
);
103 var logId
= "esign-signature-log-"+response
.formDir+
"-"+response
.formId
;
104 $
.post( formConfig
.logViewAction
, response
, function( html
) {
105 $
("#"+logId
).replaceWith( html
);
111 var encounterConfig
= <?php
echo $esignApi->encounterConfigToJson(); ?
>;
112 $
(".esign-button-encounter").esign(
115 afterFormSuccess
: function( response
) {
116 // If the response indicates a locked encounter, replace all
117 // form edit buttons with a "disabled" button, and "disable" left
118 // nav visit form links
119 if ( response
.locked
) {
120 // Lock the form edit buttons
121 $
(".form-edit-button").replaceWith( response
.editButtonHtml
);
122 // Disable the new-form capabilities in left nav
123 top
.window
.parent
.left_nav
.syncRadios();
124 // Disable the new-form capabilities in top nav of the encounter
125 $
(".encounter-form-category-li").remove();
128 var logId
= "esign-signature-log-encounter-"+response
.encounterId
;
129 $
.post( encounterConfig
.logViewAction
, response
, function( html
) {
130 $
("#"+logId
).replaceWith( html
);
136 $
("#prov_edu_res").click(function() {
137 if ( $
('#prov_edu_res').prop('checked') ) {
143 top
.restoreSession();
144 $
.post( "../../../library/ajax/amc_misc_data.php",
145 { amc_id
: "patient_edu_amc",
148 patient_id
: <?php
echo js_escape($pid); ?
>,
149 object_category
: "form_encounter",
150 object_id
: <?php
echo js_escape($encounter); ?
>,
151 csrf_token_form
: <?php
echo js_escape(collectCsrfToken()); ?
>
156 $
("#provide_sum_pat_flag").click(function() {
157 if ( $
('#provide_sum_pat_flag').prop('checked') ) {
163 top
.restoreSession();
164 $
.post( "../../../library/ajax/amc_misc_data.php",
165 { amc_id
: "provide_sum_pat_amc",
168 patient_id
: <?php
echo js_escape($pid); ?
>,
169 object_category
: "form_encounter",
170 object_id
: <?php
echo js_escape($encounter); ?
>,
171 csrf_token_form
: <?php
echo js_escape(collectCsrfToken()); ?
>
176 $
("#trans_trand_care").click(function() {
177 if ( $
('#trans_trand_care').prop('checked') ) {
179 // Enable the reconciliation checkbox
180 $
("#med_reconc_perf").removeAttr("disabled");
181 $
("#soc_provided").removeAttr("disabled");
185 //Disable the reconciliation checkbox (also uncheck it if applicable)
186 $
("#med_reconc_perf").attr("disabled", true);
187 $
("#med_reconc_perf").prop("checked",false);
188 $
("#soc_provided").attr("disabled",true);
189 $
("#soc_provided").prop("checked",false);
191 top
.restoreSession();
192 $
.post( "../../../library/ajax/amc_misc_data.php",
193 { amc_id
: "med_reconc_amc",
196 patient_id
: <?php
echo js_escape($pid); ?
>,
197 object_category
: "form_encounter",
198 object_id
: <?php
echo js_escape($encounter); ?
>,
199 csrf_token_form
: <?php
echo js_escape(collectCsrfToken()); ?
>
204 $
("#med_reconc_perf").click(function() {
205 if ( $
('#med_reconc_perf').prop('checked') ) {
206 var mode
= "complete";
209 var mode
= "uncomplete";
211 top
.restoreSession();
212 $
.post( "../../../library/ajax/amc_misc_data.php",
213 { amc_id
: "med_reconc_amc",
216 patient_id
: <?php
echo js_escape($pid); ?
>,
217 object_category
: "form_encounter",
218 object_id
: <?php
echo js_escape($encounter); ?
>,
219 csrf_token_form
: <?php
echo js_escape(collectCsrfToken()); ?
>
223 $
("#soc_provided").click(function(){
224 if($
('#soc_provided').prop('checked')){
225 var mode
= "soc_provided";
228 var mode
= "no_soc_provided";
230 top
.restoreSession();
231 $
.post( "../../../library/ajax/amc_misc_data.php",
232 { amc_id
: "med_reconc_amc",
235 patient_id
: <?php
echo js_escape($pid); ?
>,
236 object_category
: "form_encounter",
237 object_id
: <?php
echo js_escape($encounter); ?
>,
238 csrf_token_form
: <?php
echo js_escape(collectCsrfToken()); ?
>
243 $
(".deleteme").click(function(evt
) { deleteme(); evt
.stopPropogation(); });
246 // If the user was not just asked about orphaned orders, build javascript for that.
247 if (!isset($_GET['attachid'])) {
248 $ares = sqlStatement(
249 "SELECT procedure_order_id, date_ordered " .
250 "FROM procedure_order WHERE " .
251 "patient_id = ? AND encounter_id = 0 AND activity = 1 " .
252 "ORDER BY procedure_order_id",
255 echo " // Ask about attaching orphaned orders to this encounter.\n";
256 echo " var attachid = '';\n";
257 while ($arow = sqlFetchArray($ares)) {
258 $orderid = $arow['procedure_order_id'];
259 $orderdate = $arow['date_ordered'];
260 echo " if (confirm(" . xlj('There is a lab order') . " + ' ' + " . js_escape($orderid). " + ' ' + " .
261 xlj('dated') . " + ' ' + " . js_escape($orderdate) . " + ' ' + " .
262 xlj('for this patient not yet assigned to any encounter.') . " + ' ' + " .
263 xlj('Assign it to this one?') . ")) attachid += " . js_escape($orderid.",") . ";\n";
265 echo " if (attachid) location.href = 'forms.php?attachid=' + encodeURIComponent(attachid);\n";
269 <?php
if ($reviewMode) { ?
>
270 $
("body table:first").hide();
271 $
(".encounter-summary-column").hide();
272 $
(".css_button").hide();
273 $
(".css_button_small").hide();
274 $
(".encounter-summary-column:first").show();
275 $
(".title:first").text(<?php
echo xlj("Review"); ?
> +
" " + $
(".title:first").text() +
" ( " +
<?php
echo js_escape($encounter); ?
> +
" )");
279 // Process click on Delete link.
280 function deleteme() {
281 dlgopen('../deleter.php?encounterid=' +
<?php
echo js_url($encounter); ?
> +
'&csrf_token_form=' +
<?php
echo js_url(collectCsrfToken()); ?
>, '_blank', 500, 200, '', '', {
283 {text
: <?php
echo xlj('Done'); ?
>, close
: true, style
: 'primary btn-sm'}
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();
298 top
.window
.parent
.left_nav
.loadFrame('ens1', window
.parent
.name
, 'patient_file/history/encounters.php');
302 // Called to open the data entry form a specified encounter form instance.
303 function openEncounterForm(formdir
, formname
, formid
) {
304 var url
= <?php
echo js_escape($rootdir); ?
> +
'/patient_file/encounter/view_form.php?formname=' +
305 encodeURIComponent(formdir
) +
'&id=' +
encodeURIComponent(formid
);
306 if (formdir
== 'newpatient' ||
!parent
.twAddFrameTab
) {
307 top
.restoreSession();
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 js_escape($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
echo xlj('Collapse'); ?
>;
334 ele
.style
.display
= "none" ; text
.innerHTML
= <?php
echo xlj('Expand'); ?
>;
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
echo xlj('Expand'); ?
>;
347 ele
.style
.display
= "block";
348 text
.innerHTML
= <?php
echo xlj('Collapse'); ?
>;
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 ? ORDER BY category, priority, name";
524 if ($limit != "unlimited") {
525 $sql .= " limit " . escape_limit($limit) . ", " . escape_limit($offset);
527 $res = sqlStatement($sql, array($state));
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 = xl('Miscellaneous');
570 $new_category = xl($new_category);
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(" . attr_js($DivId) . ");\" >" . text($new_category) . "</a><div id='" . attr($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 attr_js($rootdir."/patient_file/encounter/load_form.php?formname=".urlencode($entry['directory'])) .
589 ", " . attr_js(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 xlt('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 attr_js($rootdir."/patient_file/encounter/load_form.php?formname=".urlencode($option_id)) .
628 ", " . attr_js(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(" . attr_js($DivId) . ");\" >" . text($new_category) . "</a><div id='" . attr($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(" . attr_js($relative_link) . ", " . attr_js(xl_form_title($nickname)) . ")\" " .
667 "href='JavaScript:void(0);'>" . text(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 " " . xlt('for') . " " . text($result['fname']) . " " . text($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 = ? AND encounter = ? LIMIT 1", array($pid, $encounter));
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 " " . xlt('for') . " " . text($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 xlt('Delete') ?
></span
></a
>
758  
; 
; 
;<a href
="#" onClick
='expandcollapse("expand");' style
="font-size:80%;"><?php
echo xlt('Expand All'); ?
></a
>
759  
; 
; 
;<a style
="font-size:80%;" href
="#" onClick
='expandcollapse("collapse");'><?php
echo xlt('Collapse All'); ?
></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 xlt('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 xlt('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 xlt('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 xlt('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 xlt('Summary Of Care Provided?') ?
></span
>
846 <input type
="checkbox" id
="trans_trand_care">
849 <span
class="text"><?php
echo xlt('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 xlt('Medication Reconciliation Performed?') ?
></span
>
864 <input type
="checkbox" id
="soc_provided" DISABLED
>
867 <span
class="text"><?php
echo xlt('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 (!empty($docs_list) && 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_url($pid) . "&document_id=" . attr_url($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="' . xla('Edit form') . '" '.
978 'id="' . attr($formdir) . '~' . attr($iter['form_id']) . '">';
980 echo '<tr id="' . attr($formdir) . '~' . attr($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='javascript:void(0);' onclick='divtoggle(" . attr_js('spanid_'.$divnos) . "," . attr_js('divid_'.$divnos) . ");' class='small' id='aid_" . attr($divnos) . "'>" .
1004 "<div class='formname'>" . text($form_name) . "</div> " .
1005 xlt('by') . " " . text($form_author) . " " .
1006 "(<span id=spanid_" . attr($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_js($formdir) . ", " .
1023 attr_js($form_name) . ", " . attr_js($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=" . attr_url($formdir) .
1039 "&formid=" . attr_url($iter['form_id']) .
1040 "&visitid=" . attr_url($encounter) .
1041 "&patientid=" . attr_url($pid) .
1042 "' class='css_button_small' title='" . xla('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=" . attr_url($formdir) .
1051 "&id=" . attr_url($iter['id']) .
1052 "&encounter=". attr_url($encounter) .
1053 "&pid=" . attr_url($pid) .
1054 "' class='css_button_small' title='" . xla('Delete this form') . "' onclick='top.restoreSession()'><span>" . xlt('Delete') . "</span></a>";
1056 ?
><a href
='javascript:;' class='css_button_small' style
='color:gray'><span
><?php
echo xlt('Delete'); ?
></span
></a
><?php
1059 echo "</div>\n"; // Added as bug fix.
1064 echo "<td valign='top' class='formrow'><div class='tab' id='divid_" . attr($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
-->