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 for graphing
56 if (file_exists(dirname(__FILE__
) . "/../../forms/track_anything/style.css")) { ?
>
57 <script type
="text/javascript" src
="<?php echo $GLOBALS['web_root']?>/interface/forms/track_anything/report.js"></script
>
58 <link rel
="stylesheet" href
="<?php echo $GLOBALS['web_root']?>/interface/forms/track_anything/style.css" type
="text/css">
62 // If the user requested attachment of any orphaned procedure orders, do it.
63 if (!empty($_GET['attachid'])) {
64 $attachid = explode(',', $_GET['attachid']);
65 foreach ($attachid as $aid) {
71 "SELECT COUNT(*) AS count FROM procedure_order WHERE " .
72 "procedure_order_id = ? AND patient_id = ? AND encounter_id = 0 AND activity = 1",
75 if (!empty($tmp['count'])) {
77 "UPDATE procedure_order SET encounter_id = ? WHERE " .
78 "procedure_order_id = ? AND patient_id = ? AND encounter_id = 0 AND activity = 1",
79 array($encounter, $aid, $pid)
81 addForm($encounter, "Procedure Order", $aid, "procedure_order", $pid, $userauthorized);
87 <script type
="text/javascript">
89 jQuery(document
).ready( function($
) {
90 var formConfig
= <?php
echo $esignApi->formConfigToJson(); ?
>;
91 $
(".esign-button-form").esign(
94 afterFormSuccess
: function( response
) {
95 if ( response
.locked
) {
96 var editButtonId
= "form-edit-button-"+response
.formDir+
"-"+response
.formId
;
97 $
("#"+editButtonId
).replaceWith( response
.editButtonHtml
);
100 var logId
= "esign-signature-log-"+response
.formDir+
"-"+response
.formId
;
101 $
.post( formConfig
.logViewAction
, response
, function( html
) {
102 $
("#"+logId
).replaceWith( html
);
108 var encounterConfig
= <?php
echo $esignApi->encounterConfigToJson(); ?
>;
109 $
(".esign-button-encounter").esign(
112 afterFormSuccess
: function( response
) {
113 // If the response indicates a locked encounter, replace all
114 // form edit buttons with a "disabled" button, and "disable" left
115 // nav visit form links
116 if ( response
.locked
) {
117 // Lock the form edit buttons
118 $
(".form-edit-button").replaceWith( response
.editButtonHtml
);
119 // Disable the new-form capabilities in left nav
120 top
.window
.parent
.left_nav
.syncRadios();
121 // Disable the new-form capabilities in top nav of the encounter
122 $
(".encounter-form-category-li").remove();
125 var logId
= "esign-signature-log-encounter-"+response
.encounterId
;
126 $
.post( encounterConfig
.logViewAction
, response
, function( html
) {
127 $
("#"+logId
).replaceWith( html
);
133 $
("#prov_edu_res").click(function() {
134 if ( $
('#prov_edu_res').prop('checked') ) {
140 top
.restoreSession();
141 $
.post( "../../../library/ajax/amc_misc_data.php",
142 { amc_id
: "patient_edu_amc",
145 patient_id
: <?php
echo js_escape($pid); ?
>,
146 object_category
: "form_encounter",
147 object_id
: <?php
echo js_escape($encounter); ?
>,
148 csrf_token_form
: <?php
echo js_escape(collectCsrfToken()); ?
>
153 $
("#provide_sum_pat_flag").click(function() {
154 if ( $
('#provide_sum_pat_flag').prop('checked') ) {
160 top
.restoreSession();
161 $
.post( "../../../library/ajax/amc_misc_data.php",
162 { amc_id
: "provide_sum_pat_amc",
165 patient_id
: <?php
echo js_escape($pid); ?
>,
166 object_category
: "form_encounter",
167 object_id
: <?php
echo js_escape($encounter); ?
>,
168 csrf_token_form
: <?php
echo js_escape(collectCsrfToken()); ?
>
173 $
("#trans_trand_care").click(function() {
174 if ( $
('#trans_trand_care').prop('checked') ) {
176 // Enable the reconciliation checkbox
177 $
("#med_reconc_perf").removeAttr("disabled");
178 $
("#soc_provided").removeAttr("disabled");
182 //Disable the reconciliation checkbox (also uncheck it if applicable)
183 $
("#med_reconc_perf").attr("disabled", true);
184 $
("#med_reconc_perf").prop("checked",false);
185 $
("#soc_provided").attr("disabled",true);
186 $
("#soc_provided").prop("checked",false);
188 top
.restoreSession();
189 $
.post( "../../../library/ajax/amc_misc_data.php",
190 { amc_id
: "med_reconc_amc",
193 patient_id
: <?php
echo js_escape($pid); ?
>,
194 object_category
: "form_encounter",
195 object_id
: <?php
echo js_escape($encounter); ?
>,
196 csrf_token_form
: <?php
echo js_escape(collectCsrfToken()); ?
>
201 $
("#med_reconc_perf").click(function() {
202 if ( $
('#med_reconc_perf').prop('checked') ) {
203 var mode
= "complete";
206 var mode
= "uncomplete";
208 top
.restoreSession();
209 $
.post( "../../../library/ajax/amc_misc_data.php",
210 { amc_id
: "med_reconc_amc",
213 patient_id
: <?php
echo js_escape($pid); ?
>,
214 object_category
: "form_encounter",
215 object_id
: <?php
echo js_escape($encounter); ?
>,
216 csrf_token_form
: <?php
echo js_escape(collectCsrfToken()); ?
>
220 $
("#soc_provided").click(function(){
221 if($
('#soc_provided').prop('checked')){
222 var mode
= "soc_provided";
225 var mode
= "no_soc_provided";
227 top
.restoreSession();
228 $
.post( "../../../library/ajax/amc_misc_data.php",
229 { amc_id
: "med_reconc_amc",
232 patient_id
: <?php
echo js_escape($pid); ?
>,
233 object_category
: "form_encounter",
234 object_id
: <?php
echo js_escape($encounter); ?
>,
235 csrf_token_form
: <?php
echo js_escape(collectCsrfToken()); ?
>
240 $
(".deleteme").click(function(evt
) { deleteme(); evt
.stopPropogation(); });
243 // If the user was not just asked about orphaned orders, build javascript for that.
244 if (!isset($_GET['attachid'])) {
245 $ares = sqlStatement(
246 "SELECT procedure_order_id, date_ordered " .
247 "FROM procedure_order WHERE " .
248 "patient_id = ? AND encounter_id = 0 AND activity = 1 " .
249 "ORDER BY procedure_order_id",
252 echo " // Ask about attaching orphaned orders to this encounter.\n";
253 echo " var attachid = '';\n";
254 while ($arow = sqlFetchArray($ares)) {
255 $orderid = $arow['procedure_order_id'];
256 $orderdate = $arow['date_ordered'];
257 echo " if (confirm(" . xlj('There is a lab order') . " + ' ' + " . js_escape($orderid). " + ' ' + " .
258 xlj('dated') . " + ' ' + " . js_escape($orderdate) . " + ' ' + " .
259 xlj('for this patient not yet assigned to any encounter.') . " + ' ' + " .
260 xlj('Assign it to this one?') . ")) attachid += " . js_escape($orderid.",") . ";\n";
262 echo " if (attachid) location.href = 'forms.php?attachid=' + encodeURIComponent(attachid);\n";
266 <?php
if ($reviewMode) { ?
>
267 $
("body table:first").hide();
268 $
(".encounter-summary-column").hide();
269 $
(".css_button").hide();
270 $
(".css_button_small").hide();
271 $
(".encounter-summary-column:first").show();
272 $
(".title:first").text(<?php
echo xlj("Review"); ?
> +
" " + $
(".title:first").text() +
" ( " +
<?php
echo js_escape($encounter); ?
> +
" )");
276 // Process click on Delete link.
277 function deleteme() {
278 dlgopen('../deleter.php?encounterid=' +
<?php
echo js_escape($encounter); ?
>, '_blank', 500, 200, '', '', {
280 {text
: <?php
echo xlj('Done'); ?
>, close
: true, style
: 'primary btn-sm'}
288 // Called by the deleter.php window on a successful delete.
289 function imdeleted(EncounterId
) {
290 top
.window
.parent
.left_nav
.removeOptionSelected(EncounterId
);
291 top
.window
.parent
.left_nav
.clearEncounter();
295 top
.window
.parent
.left_nav
.loadFrame('ens1', window
.parent
.name
, 'patient_file/history/encounters.php');
299 // Called to open the data entry form a specified encounter form instance.
300 function openEncounterForm(formdir
, formname
, formid
) {
301 var url
= <?php
echo js_escape($rootdir); ?
> +
'/patient_file/encounter/view_form.php?formname=' +
302 encodeURIComponent(formdir
) +
'&id=' +
encodeURIComponent(formid
);
303 if (formdir
== 'newpatient' ||
!parent
.twAddFrameTab
) {
304 top
.restoreSession();
308 parent
.twAddFrameTab('enctabs', formname
, url
);
313 // Called when an encounter form may changed something that requires a refresh here.
314 function refreshVisitDisplay() {
315 location
.href
= <?php
echo js_escape($rootdir); ?
> +
'/patient_file/encounter/forms.php';
320 <script language
="javascript">
321 function expandcollapse(atr
) {
322 for (var i
= 1; i
< 15; ++i
) {
323 var mydivid
="divid_" + i
; var myspanid
= "spanid_" + i
;
324 var ele
= document
.getElementById(mydivid
);
325 var text
= document
.getElementById(myspanid
);
327 if (atr
== "expand") {
328 ele
.style
.display
= "block"; text
.innerHTML
= <?php
echo xlj('Collapse'); ?
>;
331 ele
.style
.display
= "none" ; text
.innerHTML
= <?php
echo xlj('Expand'); ?
>;
336 function divtoggle(spanid
, divid
) {
337 var ele
= document
.getElementById(divid
);
338 var text
= document
.getElementById(spanid
);
339 if(ele
.style
.display
== "block") {
340 ele
.style
.display
= "none";
341 text
.innerHTML
= <?php
echo xlj('Expand'); ?
>;
344 ele
.style
.display
= "block";
345 text
.innerHTML
= <?php
echo xlj('Collapse'); ?
>;
350 <style type
="text/css">
361 div
.form_header_controls
{
375 .encounter
-summary
-container
{
380 .encounter
-summary
-column
{
388 <!-- *************** -->
389 <!-- Form menu start
-->
390 <script language
="JavaScript">
392 function openNewForm(sel
, label
) {
393 top
.restoreSession();
394 var FormNameValueArray
= sel
.split('formname=');
395 if (FormNameValueArray
[1] == 'newpatient') {
396 // TBD: Make this work when it's not the first frame.
397 parent
.frames
[0].location
.href
= sel
;
400 parent
.twAddFrameTab('enctabs', label
, sel
);
404 function toggleFrame1(fnum
) {
405 top
.frames
['left_nav'].document
.forms
[0].cb_top
.checked
=false;
406 top
.window
.parent
.left_nav
.toggleFrame(fnum
);
409 <style type
="text/css">
417 <script type
="text/javascript" language
="javascript">
422 var oldddmenuitem
= 0;
428 // cancel close timer
429 //mcancelclosetime();
434 //if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
435 //if(ddmenuitem) ddmenuitem.style.display = 'none';
437 // get new layer and show it
438 oldddmenuitem
= ddmenuitem
;
439 ddmenuitem
= document
.getElementById(id
);
440 if((ddmenuitem
.style
.visibility
== '')||
(ddmenuitem
.style
.visibility
== 'hidden')){
441 if(oldddmenuitem
) oldddmenuitem
.style
.visibility
= 'hidden';
442 if(oldddmenuitem
) oldddmenuitem
.style
.display
= 'none';
443 ddmenuitem
.style
.visibility
= 'visible';
444 ddmenuitem
.style
.display
= 'block';
446 ddmenuitem
.style
.visibility
= 'hidden';
447 ddmenuitem
.style
.display
= 'none';
450 // close showed layer
458 if(ddmenuitem
) ddmenuitem
.style
.visibility
= 'hidden';
459 if(ddmenuitem
) ddmenuitem
.style
.display
= 'none';
462 // close layer when click-out
463 document
.onclick
= mclose
;
464 //=================================================
465 function findPosX(id
)
467 obj
=document
.getElementById(id
);
472 curleft +
= obj
.offsetLeft
;
473 if(!obj
.offsetParent
)
475 obj
= obj
.offsetParent
;
479 PropertyWidth
=document
.getElementById(id
).offsetWidth
;
480 if(PropertyWidth
>curleft
)
482 document
.getElementById(id
).style
.left
=0;
486 function findPosY(obj
)
492 curtop +
= obj
.offsetTop
;
493 if(!obj
.offsetParent
)
495 obj
= obj
.offsetParent
;
504 <body
class="bgcolor2">
506 <?php
//DYNAMIC FORM RETREIVAL
507 include_once("$srcdir/registry.inc");
509 function myGetRegistered($state = "1", $limit = "unlimited", $offset = "0")
511 global $attendant_type;
512 $sql = "SELECT category, nickname, name, state, directory, id, sql_run, " .
513 "unpackaged, date, aco_spec FROM registry WHERE ";
514 // select different forms for groups
515 if ($attendant_type == 'pid') {
516 $sql .= "patient_encounter = 1 AND ";
518 $sql .= "therapy_group_encounter = 1 AND ";
520 $sql .= "state LIKE ? ORDER BY category, priority, name";
521 if ($limit != "unlimited") {
522 $sql .= " limit " . escape_limit($limit) . ", " . escape_limit($offset);
524 $res = sqlStatement($sql, array($state));
526 for ($iter=0; $row=sqlFetchArray($res); $iter++
) {
535 $reg = myGetRegistered();
540 // To see if the encounter is locked. If it is, no new forms can be created
541 $encounterLocked = false;
542 if ($esignApi->lockEncounters() &&
543 isset($GLOBALS['encounter']) &&
544 !empty($GLOBALS['encounter']) ) {
545 $esign = $esignApi->createEncounterESign($GLOBALS['encounter']);
546 if ($esign->isLocked()) {
547 $encounterLocked = true;
552 $StringEcho= '<ul id="sddm">';
553 if ($encounterLocked === false) {
554 foreach ($reg as $entry) {
555 // Check permission to create forms of this type.
556 $tmp = explode('|', $entry['aco_spec']);
557 if (!empty($tmp[1])) {
558 if (!acl_check($tmp[0], $tmp[1], '', 'write') && !acl_check($tmp[0], $tmp[1], '', 'addonly')) {
562 $new_category = trim($entry['category']);
563 $new_nickname = trim($entry['nickname']);
564 if ($new_category == '') {
565 $new_category = xl('Miscellaneous');
567 $new_category = xl($new_category);
569 if ($new_nickname != '') {
570 $nickname = $new_nickname;
572 $nickname = trim($entry['name']);
574 if ($old_category != $new_category) {
575 $new_category_ = $new_category;
576 $new_category_ = str_replace(' ', '_', $new_category_);
577 if ($old_category != '') {
578 $StringEcho .= "</table></div></li>";
580 $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'>";
581 $old_category = $new_category;
584 $StringEcho .= "<tr><td style='border-top: 1px solid #000000;padding:0px;'><a onclick=\"openNewForm(" .
585 attr_js($rootdir."/patient_file/encounter/load_form.php?formname=".urlencode($entry['directory'])) .
586 ", " . attr_js(xl_form_title($nickname)) . ")\" href='JavaScript:void(0);'>" .
587 text(xl_form_title($nickname)) . "</a></td></tr>";
590 $StringEcho.= '</table></div></li>';
594 $StringEcho2= '<div style="clear:both"></div>';
599 // This shows Layout Based Form names just like the above.
601 if ($encounterLocked === false) {
602 $lres = sqlStatement("SELECT grp_form_id AS option_id, grp_title AS title, grp_aco_spec " .
603 "FROM layout_group_properties WHERE " .
604 "grp_form_id LIKE 'LBF%' AND grp_group_id = '' AND grp_activity = 1 " .
605 "ORDER BY grp_seq, grp_title");
607 if (sqlNumRows($lres)) {
609 $StringEcho= '<ul id="sddm">';
611 $StringEcho.= "<li class=\"encounter-form-category-li\"><a href='JavaScript:void(0);' onClick=\"mopen('lbf');\" >" .
612 xlt('Layout Based') . "</a><div id='lbf' ><table border='0' cellspacing='0' cellpadding='0'>";
613 while ($lrow = sqlFetchArray($lres)) {
614 $option_id = $lrow['option_id']; // should start with LBF
615 $title = $lrow['title'];
616 // Check ACO attribute, if any, of this LBF.
617 if (!empty($lrow['grp_aco_spec'])) {
618 $tmp = explode('|', $lrow['grp_aco_spec']);
619 if (!acl_check($tmp[0], $tmp[1], '', 'write') && !acl_check($tmp[0], $tmp[1], '', 'addonly')) {
623 $StringEcho .= "<tr><td style='border-top: 1px solid #000000;padding:0px;'><a onclick=\"openNewForm(" .
624 attr_js($rootdir."/patient_file/encounter/load_form.php?formname=".urlencode($option_id)) .
625 ", " . attr_js(xl_form_title($title)) . ")\" href='JavaScript:void(0);'>" .
626 text(xl_form_title($title)) . "</a></td></tr>";
631 <!-- DISPLAYING HOOKS STARTS HERE
-->
633 $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
634 obj_name=enabled_hooks AND ms.mod_id=msh.mod_id LEFT OUTER JOIN modules AS m ON m.mod_id=ms.mod_id
635 WHERE fld_type=3 AND mod_active=1 AND sql_run=1 AND attached_to='encounter' ORDER BY mod_id");
636 $DivId = 'mod_installer';
637 if (sqlNumRows($module_query)) {
640 while ($modulerow = sqlFetchArray($module_query)) {
641 $DivId = 'mod_'.$modulerow['mod_id'];
642 $new_category = $modulerow['mod_ui_name'];
645 if ($modulerow['type'] == 0) {
646 $modulePath = $GLOBALS['customModDir'];
650 $modulePath = $GLOBALS['zendModDir'];
652 $relative_link = "../../modules/".$modulePath."/".$modulerow['path'];
653 $nickname = $modulerow['menu_name'] ?
$modulerow['menu_name'] : 'Noname';
654 if ($jid==0 ||
($modid!=$modulerow['mod_id'])) {
656 $StringEcho.= '</table></div></li>';
658 $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'>";
661 $modid = $modulerow['mod_id'];
662 $StringEcho.= "<tr><td style='border-top: 1px solid #000000;padding:0px;'><a onclick=" .
663 "\"openNewForm(" . attr_js($relative_link) . ", " . attr_js(xl_form_title($nickname)) . ")\" " .
664 "href='JavaScript:void(0);'>" . text(xl_form_title($nickname)) . "</a></td></tr>";
668 <!-- DISPLAYING HOOKS ENDS HERE
-->
671 $StringEcho.= "</table></div></li></ul>".$StringEcho2;
674 <table cellspacing
="0" cellpadding
="0" align
="center">
676 <td valign
="top"><?php
echo $StringEcho; ?
></td
>
680 <!-- Form menu stop
-->
681 <!-- *************** -->
683 <div id
="encounter_forms">
686 $dateres = getEncounterDateByEncounter($encounter);
687 $encounter_date = date("Y-m-d", strtotime($dateres["date"]));
688 $providerIDres = getProviderIdOfEncounter($encounter);
689 $providerNameRes = getProviderName($providerIDres);
692 <div
class='encounter-summary-container'>
693 <div
class='encounter-summary-column'>
696 $pass_sens_squad = true;
698 //fetch acl for category of given encounter
699 $pc_catid = fetchCategoryIdByEncounter($encounter);
700 $postCalendarCategoryACO = fetchPostCalendarCategoryACO($pc_catid);
701 if ($postCalendarCategoryACO) {
702 $postCalendarCategoryACO = explode('|', $postCalendarCategoryACO);
703 $authPostCalendarCategory = acl_check($postCalendarCategoryACO[0], $postCalendarCategoryACO[1]);
704 $authPostCalendarCategoryWrite = acl_check($postCalendarCategoryACO[0], $postCalendarCategoryACO[1], '', 'write');
705 } else { // if no aco is set for category
706 $authPostCalendarCategory = true;
707 $authPostCalendarCategoryWrite = true;
710 if ($attendant_type == 'pid' && is_numeric($pid)) {
711 echo '<span class="title">' . text(oeFormatShortDate($encounter_date)) . " " . xlt("Encounter") . '</span>';
713 // Check for no access to the patient's squad.
714 $result = getPatientData($pid, "fname,lname,squad");
715 echo " " . xlt('for') . " " . text($result['fname']) . " " . text($result['lname']);
716 if ($result['squad'] && ! acl_check('squads', $result['squad'])) {
717 $pass_sens_squad = false;
720 // Check for no access to the encounter's sensitivity level.
721 $result = sqlQuery("SELECT sensitivity FROM form_encounter WHERE " .
722 "pid = ? AND encounter = ? LIMIT 1", array($pid, $encounter));
723 if (($result['sensitivity'] && !acl_check('sensitivities', $result['sensitivity'])) ||
!$authPostCalendarCategory) {
724 $pass_sens_squad = false;
728 echo '<span class="title">' . text(oeFormatShortDate($encounter_date)) . " " . xlt("Group Encounter") . '</span>';
729 // Check for no access to the patient's squad.
730 $result = getGroup($groupId);
731 echo " " . xlt('for') . " " . text($result['group_name']);
732 if ($result['squad'] && ! acl_check('squads', $result['squad'])) {
733 $pass_sens_squad = false;
735 // Check for no access to the encounter's sensitivity level.
736 $result = sqlQuery("SELECT sensitivity FROM form_groups_encounter WHERE " .
737 "group_id = ? AND encounter = ? LIMIT 1", array($groupId, $encounter));
738 if (($result['sensitivity'] && !acl_check('sensitivities', $result['sensitivity'])) ||
!$authPostCalendarCategory) {
739 $pass_sens_squad = false;
744 <div style
='margin-top:8px;'>
746 // ESign for entire encounter
747 $esign = $esignApi->createEncounterESign($encounter);
748 if ($esign->isButtonViewable()) {
749 echo $esign->buttonHtml();
752 <?php
if (acl_check('admin', 'super')) { ?
>
753 <a href
='#' class='css_button' onclick
='return deleteme()'><span
><?php
echo xlt('Delete') ?
></span
></a
>
755  
; 
; 
;<a href
="#" onClick
='expandcollapse("expand");' style
="font-size:80%;"><?php
echo xlt('Expand All'); ?
></a
>
756  
; 
; 
;<a style
="font-size:80%;" href
="#" onClick
='expandcollapse("collapse");'><?php
echo xlt('Collapse All'); ?
></a
>
760 <div
class='encounter-summary-column'>
761 <?php
if ($esign->isLogViewable()) {
766 <div
class='encounter-summary-column'>
767 <?php
if ($GLOBALS['enable_amc_prompting']) { ?
>
768 <div style
='float:right;margin-right:25px;border-style:solid;border-width:1px;'>
769 <div style
='float:left;margin:5px 5px 5px 5px;'>
773 <?php
// Display the education resource checkbox (AMC prompting)
774 $itemAMC = amcCollect("patient_edu_amc", $pid, 'form_encounter', $encounter);
776 <?php
if (!(empty($itemAMC))) { ?
>
777 <input type
="checkbox" id
="prov_edu_res" checked
>
779 <input type
="checkbox" id
="prov_edu_res">
783 <span
class="text"><?php
echo xlt('Provided Education Resource(s)?') ?
></span
>
788 <?php
// Display the Provided Clinical Summary checkbox (AMC prompting)
789 $itemAMC = amcCollect("provide_sum_pat_amc", $pid, 'form_encounter', $encounter);
791 <?php
if (!(empty($itemAMC))) { ?
>
792 <input type
="checkbox" id
="provide_sum_pat_flag" checked
>
794 <input type
="checkbox" id
="provide_sum_pat_flag">
798 <span
class="text"><?php
echo xlt('Provided Clinical Summary?') ?
></span
>
801 <?php
// Display the medication reconciliation checkboxes (AMC prompting)
802 $itemAMC = amcCollect("med_reconc_amc", $pid, 'form_encounter', $encounter);
804 <?php
if (!(empty($itemAMC))) { ?
>
807 <input type
="checkbox" id
="trans_trand_care" checked
>
810 <span
class="text"><?php
echo xlt('Transition/Transfer of Care?') ?
></span
>
814 <table style
="margin-left:2em;">
817 <?php
if (!(empty($itemAMC['date_completed']))) { ?
>
818 <input type
="checkbox" id
="med_reconc_perf" checked
>
820 <input type
="checkbox" id
="med_reconc_perf">
824 <span
class="text"><?php
echo xlt('Medication Reconciliation Performed?') ?
></span
>
829 <?php
if (!(empty($itemAMC['soc_provided']))) { ?
>
830 <input type
="checkbox" id
="soc_provided" checked
>
832 <input type
="checkbox" id
="soc_provided">
836 <span
class="text"><?php
echo xlt('Summary Of Care Provided?') ?
></span
>
843 <input type
="checkbox" id
="trans_trand_care">
846 <span
class="text"><?php
echo xlt('Transition/Transfer of Care?') ?
></span
>
850 <table style
="margin-left:2em;">
853 <input type
="checkbox" id
="med_reconc_perf" DISABLED
>
856 <span
class="text"><?php
echo xlt('Medication Reconciliation Performed?') ?
></span
>
861 <input type
="checkbox" id
="soc_provided" DISABLED
>
864 <span
class="text"><?php
echo xlt('Summary of Care Provided?') ?
></span
>
876 <!-- Get the documents tagged to this encounter
and display the links
and notes
as the tooltip
-->
878 if ($attendant_type == 'pid') {
879 $docs_list = getDocumentsByEncounter($pid, $_SESSION['encounter']);
881 // already doesn't exist document for therapy groups
882 $docs_list = array();
884 if (!empty($docs_list) && count($docs_list) > 0) {
886 <div
class='enc_docs'>
887 <span
class="bold"><?php
echo xlt("Document(s)"); ?
>:</span
>
889 $doc = new C_Document();
890 foreach ($docs_list as $doc_iter) {
891 $doc_url = $doc->_tpl_vars
[CURRENT_ACTION
]. "&view&patient_id=" . attr_url($pid) . "&document_id=" . attr_url($doc_iter[id
]) . "&";
892 // Get notes for this document.
893 $queryString = "SELECT GROUP_CONCAT(note ORDER BY date DESC SEPARATOR '|') AS docNotes, GROUP_CONCAT(date ORDER BY date DESC SEPARATOR '|') AS docDates
894 FROM notes WHERE foreign_id = ? GROUP BY foreign_id";
895 $noteData = sqlQuery($queryString, array($doc_iter['id']));
899 $notes = explode("|", $noteData['docNotes']);
900 $dates = explode("|", $noteData['docDates']);
901 for ($i = 0; $i < count($notes); $i++
) {
902 $note .= oeFormatShortDate(date('Y-m-d', strtotime($dates[$i]))) . " : " . $notes[$i] . "\n";
907 <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
>
908 <?php
if ($note != '') {?
>
909 <a href
="javascript:void(0);" title
="<?php echo attr($note);?>"><img src
="../../../images/info.png"/></a
>
917 if ($pass_sens_squad &&
918 ($result = getFormByEncounter(
921 "id, date, form_id, form_name, formdir, user, deleted",
923 "FIND_IN_SET(formdir,'newpatient') DESC, form_name, date DESC"
925 echo "<table width='100%' id='partable'>";
927 foreach ($result as $iter) {
928 $formdir = $iter['formdir'];
930 // skip forms whose 'deleted' flag is set to 1
931 if ($iter['deleted'] == 1) {
937 if (substr($formdir, 0, 3) == 'LBF') {
938 // Skip LBF forms that we are not authorized to see.
940 "SELECT grp_aco_spec " .
941 "FROM layout_group_properties WHERE " .
942 "grp_form_id = ? AND grp_group_id = '' AND grp_activity = 1",
946 if (!empty($lrow['grp_aco_spec'])) {
947 $aco_spec = explode('|', $lrow['grp_aco_spec']);
948 if (!acl_check($aco_spec[0], $aco_spec[1])) {
954 // Skip non-LBF forms that we are not authorized to see.
955 $tmp = getRegistryEntryByDirectory($formdir, 'aco_spec');
956 if (!empty($tmp['aco_spec'])) {
957 $aco_spec = explode('|', $tmp['aco_spec']);
958 if (!acl_check($aco_spec[0], $aco_spec[1])) {
964 // $form_info = getFormInfoById($iter['id']);
965 if (strtolower(substr($iter['form_name'], 0, 5)) == 'camos') {
966 //CAMOS generates links from report.php and these links should
967 //be clickable without causing view.php to come up unexpectedly.
968 //I feel that the JQuery code in this file leading to a click
969 //on the report.php content to bring up view.php steps on a
970 //form's autonomy to generate it's own html content in it's report
971 //but until any other form has a problem with this, I will just
972 //make an exception here for CAMOS and allow it to carry out this
973 //functionality for all other forms. --Mark
974 echo '<tr title="' . xla('Edit form') . '" '.
975 'id="' . attr($formdir) . '~' . attr($iter['form_id']) . '">';
977 echo '<tr id="' . attr($formdir) . '~' . attr($iter['form_id']) . '" class="text onerow">';
980 $acl_groups = acl_check("groups", "glog", false, 'write') ?
true : false;
981 $user = getNameFromUsername($iter['user']);
983 $form_name = ($formdir == 'newpatient') ?
xl('Visit Summary') : xl_form_title($iter['form_name']);
985 // Create the ESign instance for this form
986 $esign = $esignApi->createFormESign($iter['id'], $formdir, $encounter);
988 // echo "<tr>"; // Removed as bug fix.
990 echo "<td style='border-bottom:1px solid'>";
992 // Figure out the correct author (encounter authors are the '$providerNameRes', while other
993 // form authors are the '$user['fname'] . " " . $user['lname']').
994 if ($formdir == 'newpatient') {
995 $form_author = $providerNameRes;
997 $form_author = $user['fname'] . " " . $user['lname'];
999 echo "<div class='form_header'>";
1000 echo "<a href='#' onclick='divtoggle(" . attr_js('spanid_'.$divnos) . "," . attr_js('divid_'.$divnos) . ");' class='small' id='aid_" . attr($divnos) . "'>" .
1001 "<div class='formname'>" . text($form_name) . "</div> " .
1002 xlt('by') . " " . text($form_author) . " " .
1003 "(<span id=spanid_" . attr($divnos) . " class=\"indicator\">" . ($divnos == 1 ?
xlt('Collapse') : xlt('Expand')) . "</span>)</a>";
1006 // a link to edit the form
1007 echo "<div class='form_header_controls'>";
1009 // If the form is locked, it is no longer editable
1010 if ($esign->isLocked()) {
1011 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>";
1013 if ((!$aco_spec ||
acl_check($aco_spec[0], $aco_spec[1], '', 'write') and $is_group == 0 and $authPostCalendarCategoryWrite)
1014 or (((!$aco_spec ||
acl_check($aco_spec[0], $aco_spec[1], '', 'write')) and $is_group and acl_check("groups", "glog", false, 'write')) and $authPostCalendarCategoryWrite)) {
1015 echo "<a class='css_button_small form-edit-button' " .
1016 "id='form-edit-button-" . attr($formdir) . "-" . attr($iter['id']) . "' " .
1018 "title='" . xla('Edit this form') . "' " .
1019 "onclick=\"return openEncounterForm(" . attr_js($formdir) . ", " .
1020 attr_js($form_name) . ", " . attr_js($iter['form_id']) . ")\">";
1021 echo "<span>" . xlt('Edit') . "</span></a>";
1025 if (($esign->isButtonViewable() and $is_group == 0 and $authPostCalendarCategoryWrite) or ($esign->isButtonViewable() and $is_group and acl_check("groups", "glog", false, 'write') and $authPostCalendarCategoryWrite)) {
1026 if (!$aco_spec ||
acl_check($aco_spec[0], $aco_spec[1], '', 'write')) {
1027 echo $esign->buttonHtml();
1031 if (substr($formdir, 0, 3) == 'LBF') {
1032 // A link for a nice printout of the LBF
1033 echo "<a target='_blank' " .
1034 "href='$rootdir/forms/LBF/printable.php?" .
1035 "formname=" . attr_url($formdir) .
1036 "&formid=" . attr_url($iter['form_id']) .
1037 "&visitid=" . attr_url($encounter) .
1038 "&patientid=" . attr_url($pid) .
1039 "' class='css_button_small' title='" . xla('Print this form') .
1040 "' onclick='top.restoreSession()'><span>" . xlt('Print') . "</span></a>";
1043 if (acl_check('admin', 'super')) {
1044 if ($formdir != 'newpatient' && $formdir != 'newGroupEncounter') {
1045 // a link to delete the form from the encounter
1046 echo "<a href='$rootdir/patient_file/encounter/delete_form.php?" .
1047 "formname=" . attr_url($formdir) .
1048 "&id=" . attr_url($iter['id']) .
1049 "&encounter=". attr_url($encounter) .
1050 "&pid=" . attr_url($pid) .
1051 "' class='css_button_small' title='" . xla('Delete this form') . "' onclick='top.restoreSession()'><span>" . xlt('Delete') . "</span></a>";
1053 ?
><a href
='javascript:;' class='css_button_small' style
='color:gray'><span
><?php
echo xlt('Delete'); ?
></span
></a
><?php
1056 echo "</div>\n"; // Added as bug fix.
1061 echo "<td valign='top' class='formrow'><div class='tab' id='divid_" . attr($divnos) . "' ";
1062 echo "style='display:" . ($divnos == 1 ?
'block' : 'none') . "'>";
1064 // Use the form's report.php for display. Forms with names starting with LBF
1065 // are list-based forms sharing a single collection of code.
1067 if (substr($formdir, 0, 3) == 'LBF') {
1068 include_once($GLOBALS['incdir'] . "/forms/LBF/report.php");
1070 call_user_func("lbf_report", $attendant_id, $encounter, 2, $iter['form_id'], $formdir, true);
1072 include_once($GLOBALS['incdir'] . "/forms/$formdir/report.php");
1073 call_user_func($formdir . "_report", $attendant_id, $encounter, 2, $iter['form_id']);
1076 if ($esign->isLogViewable()) {
1077 $esign->renderLog();
1080 echo "</div></td></tr>";
1085 if (!$pass_sens_squad) {
1086 echo xlt("Not authorized to view this encounter");
1090 </div
> <!-- end large encounter_forms DIV
-->