consolidated reviewMode in forms.php (this can then be used for view only acl users...
[openemr.git] / interface / patient_file / encounter / forms.php
blobd3e3d8366bc0bc5d6424e2a164825d83c445f25f
1 <?php
2 use ESign\Api;
3 // This program is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU General Public License
5 // as published by the Free Software Foundation; either version 2
6 // of the License, or (at your option) any later version.
8 require_once("../../globals.php");
9 require_once("$srcdir/forms.inc");
10 require_once("$srcdir/group.inc");
11 require_once("$srcdir/calendar.inc");
12 require_once("$srcdir/acl.inc");
13 require_once("$srcdir/patient.inc");
14 require_once("$srcdir/amc.php");
15 require_once $GLOBALS['srcdir'].'/ESign/Api.php';
16 require_once("$srcdir/../controllers/C_Document.class.php");
18 $reviewMode = false;
19 if (!empty($_REQUEST['review_id'])) {
20 $reviewMode = true;
21 $encounter=$_REQUEST['review_id'];
24 $is_group = ($attendant_type == 'gid') ? true : false;
25 if($attendant_type == 'gid'){
26 $groupId = $therapy_group;
28 $attendant_id = $attendant_type == 'pid' ? $pid : $therapy_group;
29 if($is_group && !acl_check("groups","glog",false, array('view','write'))){
30 echo xlt("access not allowed");
31 exit();
35 <html>
37 <head>
39 <?php require $GLOBALS['srcdir'] . '/js/xl/dygraphs.js.php'; ?>
41 <?php html_header_show();?>
42 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
43 <link rel="stylesheet" type="text/css" href="<?php echo $GLOBALS['webroot'] ?>/library/ESign/css/esign.css" />
44 <link rel="stylesheet" href="<?php echo $GLOBALS['assets_static_relative']; ?>/modified/dygraphs-2-0-0/dygraph.css" type="text/css"></script>
46 <!-- supporting javascript code -->
47 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-3-1-1/index.js"></script>
48 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/dialog.js?v=<?php echo $v_js_includes; ?>"></script>
49 <script type="text/javascript" src="../../../library/textformat.js"></script>
50 <script type="text/javascript" src="../../../library/js/common.js"></script>
51 <script src="<?php echo $GLOBALS['webroot'] ?>/library/ESign/js/jquery.esign.js"></script>
52 <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>
54 <?php
55 $esignApi = new Api();
58 <?php // if the track_anything form exists, then include the styling and js functions for graphing
59 if (file_exists(dirname(__FILE__) . "/../../forms/track_anything/style.css")) { ?>
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">
62 <?php } ?>
64 <?php
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) {
69 $aid = intval($aid);
70 if (!$aid) continue;
71 $tmp = sqlQuery("SELECT COUNT(*) AS count FROM procedure_order WHERE " .
72 "procedure_order_id = ? AND patient_id = ? AND encounter_id = 0 AND activity = 1",
73 array($aid, $pid));
74 if (!empty($tmp['count'])) {
75 sqlStatement("UPDATE procedure_order SET encounter_id = ? WHERE " .
76 "procedure_order_id = ? AND patient_id = ? AND encounter_id = 0 AND activity = 1",
77 array($encounter, $aid, $pid));
78 addForm($encounter, "Procedure Order", $aid, "procedure_order", $pid, $userauthorized);
84 <script type="text/javascript">
85 $.noConflict();
86 jQuery(document).ready( function($) {
87 var formConfig = <?php echo $esignApi->formConfigToJson(); ?>;
88 $(".esign-button-form").esign(
89 formConfig,
91 afterFormSuccess : function( response ) {
92 if ( response.locked ) {
93 var editButtonId = "form-edit-button-"+response.formDir+"-"+response.formId;
94 $("#"+editButtonId).replaceWith( response.editButtonHtml );
97 var logId = "esign-signature-log-"+response.formDir+"-"+response.formId;
98 $.post( formConfig.logViewAction, response, function( html ) {
99 $("#"+logId).replaceWith( html );
105 var encounterConfig = <?php echo $esignApi->encounterConfigToJson(); ?>;
106 $(".esign-button-encounter").esign(
107 encounterConfig,
109 afterFormSuccess : function( response ) {
110 // If the response indicates a locked encounter, replace all
111 // form edit buttons with a "disabled" button, and "disable" left
112 // nav visit form links
113 if ( response.locked ) {
114 // Lock the form edit buttons
115 $(".form-edit-button").replaceWith( response.editButtonHtml );
116 // Disable the new-form capabilities in left nav
117 top.window.parent.left_nav.syncRadios();
118 // Disable the new-form capabilities in top nav of the encounter
119 $(".encounter-form-category-li").remove();
122 var logId = "esign-signature-log-encounter-"+response.encounterId;
123 $.post( encounterConfig.logViewAction, response, function( html ) {
124 $("#"+logId).replaceWith( html );
130 $(".onerow").mouseover(function() { $(this).toggleClass("highlight"); });
131 $(".onerow").mouseout(function() { $(this).toggleClass("highlight"); });
132 $(".onerow").click(function() { GotoForm(this); });
134 $("#prov_edu_res").click(function() {
135 if ( $('#prov_edu_res').prop('checked') ) {
136 var mode = "add";
138 else {
139 var mode = "remove";
141 top.restoreSession();
142 $.post( "../../../library/ajax/amc_misc_data.php",
143 { amc_id: "patient_edu_amc",
144 complete: true,
145 mode: mode,
146 patient_id: <?php echo htmlspecialchars($pid,ENT_NOQUOTES); ?>,
147 object_category: "form_encounter",
148 object_id: <?php echo htmlspecialchars($encounter,ENT_NOQUOTES); ?>
153 $("#provide_sum_pat_flag").click(function() {
154 if ( $('#provide_sum_pat_flag').prop('checked') ) {
155 var mode = "add";
157 else {
158 var mode = "remove";
160 top.restoreSession();
161 $.post( "../../../library/ajax/amc_misc_data.php",
162 { amc_id: "provide_sum_pat_amc",
163 complete: true,
164 mode: mode,
165 patient_id: <?php echo htmlspecialchars($pid,ENT_NOQUOTES); ?>,
166 object_category: "form_encounter",
167 object_id: <?php echo htmlspecialchars($encounter,ENT_NOQUOTES); ?>
172 $("#trans_trand_care").click(function() {
173 if ( $('#trans_trand_care').prop('checked') ) {
174 var mode = "add";
175 // Enable the reconciliation checkbox
176 $("#med_reconc_perf").removeAttr("disabled");
177 $("#soc_provided").removeAttr("disabled");
179 else {
180 var mode = "remove";
181 //Disable the reconciliation checkbox (also uncheck it if applicable)
182 $("#med_reconc_perf").attr("disabled", true);
183 $("#med_reconc_perf").prop("checked",false);
184 $("#soc_provided").attr("disabled",true);
185 $("#soc_provided").prop("checked",false);
187 top.restoreSession();
188 $.post( "../../../library/ajax/amc_misc_data.php",
189 { amc_id: "med_reconc_amc",
190 complete: false,
191 mode: mode,
192 patient_id: <?php echo htmlspecialchars($pid,ENT_NOQUOTES); ?>,
193 object_category: "form_encounter",
194 object_id: <?php echo htmlspecialchars($encounter,ENT_NOQUOTES); ?>
199 $("#med_reconc_perf").click(function() {
200 if ( $('#med_reconc_perf').prop('checked') ) {
201 var mode = "complete";
203 else {
204 var mode = "uncomplete";
206 top.restoreSession();
207 $.post( "../../../library/ajax/amc_misc_data.php",
208 { amc_id: "med_reconc_amc",
209 complete: true,
210 mode: mode,
211 patient_id: <?php echo htmlspecialchars($pid,ENT_NOQUOTES); ?>,
212 object_category: "form_encounter",
213 object_id: <?php echo htmlspecialchars($encounter,ENT_NOQUOTES); ?>
217 $("#soc_provided").click(function(){
218 if($('#soc_provided').prop('checked')){
219 var mode = "soc_provided";
221 else{
222 var mode = "no_soc_provided";
224 top.restoreSession();
225 $.post( "../../../library/ajax/amc_misc_data.php",
226 { amc_id: "med_reconc_amc",
227 complete: true,
228 mode: mode,
229 patient_id: <?php echo htmlspecialchars($pid,ENT_NOQUOTES); ?>,
230 object_category: "form_encounter",
231 object_id: <?php echo htmlspecialchars($encounter,ENT_NOQUOTES); ?>
236 $(".deleteme").click(function(evt) { deleteme(); evt.stopPropogation(); });
238 var GotoForm = function(obj) {
239 var parts = $(obj).attr("id").split("~");
240 top.restoreSession();
241 parent.location.href = "<?php echo $rootdir; ?>/patient_file/encounter/view_form.php?formname="+parts[0]+"&id="+parts[1];
244 <?php
245 // If the user was not just asked about orphaned orders, build javascript for that.
246 if (!isset($_GET['attachid'])) {
247 $ares = sqlStatement("SELECT procedure_order_id, date_ordered " .
248 "FROM procedure_order WHERE " .
249 "patient_id = ? AND encounter_id = 0 AND activity = 1 " .
250 "ORDER BY procedure_order_id",
251 array($pid));
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('" . xls('There is a lab order') . " $orderid " .
258 xls('dated') . " $orderdate " .
259 xls('for this patient not yet assigned to any encounter.') . " " .
260 xls('Assign it to this one?') . "')) attachid += '$orderid,';\n";
262 echo " if (attachid) location.href = 'forms.php?attachid=' + 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 xls("Review"); ?> " + $(".title:first").text() + " ("+<?php echo addslashes($encounter); ?>+")");
273 <?php } ?>
276 // Process click on Delete link.
277 function deleteme() {
278 dlgopen('../deleter.php?encounterid=<?php echo $encounter; ?>', '_blank', 500, 450);
279 return false;
282 // Called by the deleter.php window on a successful delete.
283 function imdeleted(EncounterId) {
284 top.window.parent.left_nav.removeOptionSelected(EncounterId);
285 top.window.parent.left_nav.clearEncounter();
288 </script>
290 <script language="javascript">
291 function expandcollapse(atr){
292 if(atr == "expand") {
293 for(i=1;i<15;i++){
294 var mydivid="divid_"+i;var myspanid="spanid_"+i;
295 var ele = document.getElementById(mydivid); var text = document.getElementById(myspanid);
296 if (typeof(ele) != 'undefined' && ele != null)
297 ele.style.display = "block";
298 if (typeof(text) != 'undefined' && text != null)
299 text.innerHTML = "<?php xl('Collapse','e'); ?>";
302 else {
303 for(i=1;i<15;i++){
304 var mydivid="divid_"+i;var myspanid="spanid_"+i;
305 var ele = document.getElementById(mydivid); var text = document.getElementById(myspanid);
306 if (typeof(ele) != 'undefined' && ele != null)
307 ele.style.display = "none";
308 if (typeof(text) != 'undefined' && text != null)
309 text.innerHTML = "<?php xl('Expand','e'); ?>";
315 function divtoggle(spanid, divid) {
316 var ele = document.getElementById(divid);
317 var text = document.getElementById(spanid);
318 if(ele.style.display == "block") {
319 ele.style.display = "none";
320 text.innerHTML = "<?php xl('Expand','e'); ?>";
322 else {
323 ele.style.display = "block";
324 text.innerHTML = "<?php xl('Collapse','e'); ?>";
327 </script>
329 <style type="text/css">
330 div.tab {
331 min-height: 50px;
332 padding:8px;
335 div.form_header_controls {
336 float:left;margin-bottom:2px;
339 div.form_header {
340 float:left;
341 margin-left:6px;
344 .encounter-summary-container {
345 float:left;
346 width:100%;
349 .encounter-summary-column {
350 width: 33.3%;
351 float:left;
352 display:inline;
353 margin-top:10px;
355 </style>
357 <?php
358 $hide=1;
359 require_once("$incdir/patient_file/encounter/new_form.php");
362 <div id="encounter_forms">
364 <?php
365 $dateres = getEncounterDateByEncounter($encounter);
366 $encounter_date = date("Y-m-d",strtotime($dateres["date"]));
367 $providerIDres = getProviderIdOfEncounter($encounter);
368 $providerNameRes = getProviderName($providerIDres);
371 <div class='encounter-summary-container'>
372 <div class='encounter-summary-column'>
373 <div>
374 <?php
375 $pass_sens_squad = true;
377 if ($attendant_type == 'pid' && is_numeric($pid)) {
379 echo '<span class="title">' . oeFormatShortDate($encounter_date) . " " . xlt("Encounter") . '</span>';
381 // Check for no access to the patient's squad.
382 $result = getPatientData($pid, "fname,lname,squad");
383 echo htmlspecialchars( xl('for','',' ',' ') . $result['fname'] . " " . $result['lname'] );
384 if ($result['squad'] && ! acl_check('squads', $result['squad'])) {
385 $pass_sens_squad = false;
387 // Check for no access to the encounter's sensitivity level.
388 $result = sqlQuery("SELECT sensitivity FROM form_encounter WHERE " .
389 "pid = '$pid' AND encounter = '$encounter' LIMIT 1");
390 if ($result['sensitivity'] && !acl_check('sensitivities', $result['sensitivity'])) {
391 $pass_sens_squad = false;
393 // for therapy group
394 } else {
396 echo '<span class="title">' . oeFormatShortDate($encounter_date) . " " . xlt("Group Encounter") . '</span>';
397 // Check for no access to the patient's squad.
398 $result = getGroup($groupId);
399 echo htmlspecialchars( xl('for ','',' ',' ') . $result['group_name'] );
400 if ($result['squad'] && ! acl_check('squads', $result['squad'])) {
401 $pass_sens_squad = false;
403 // Check for no access to the encounter's sensitivity level.
404 $result = sqlQuery("SELECT sensitivity FROM form_groups_encounter WHERE " .
405 "group_id = ? AND encounter = ? LIMIT 1", array($groupId, $encounter));
406 if ($result['sensitivity'] && !acl_check('sensitivities', $result['sensitivity'])) {
407 $pass_sens_squad = false;
411 </div>
412 <div style='margin-top:8px;'>
413 <?php
414 // ESign for entire encounter
415 $esign = $esignApi->createEncounterESign( $encounter );
416 if ( $esign->isButtonViewable() ) {
417 echo $esign->buttonHtml();
420 <?php if (acl_check('admin', 'super')) { ?>
421 <a href='toggledivs(this.id,this.id);' class='css_button' onclick='return deleteme()'><span><?php echo xl('Delete') ?></span></a>
422 <?php } ?>
423 &nbsp;&nbsp;&nbsp;<a href="#" onClick='expandcollapse("expand");' style="font-size:80%;"><?php xl('Expand All','e'); ?></a>
424 &nbsp;&nbsp;&nbsp;<a style="font-size:80%;" href="#" onClick='expandcollapse("collapse");'><?php xl('Collapse All','e'); ?></a>
425 </div>
426 </div>
428 <div class='encounter-summary-column'>
429 <?php if ( $esign->isLogViewable() ) {
430 $esign->renderLog();
431 } ?>
432 </div>
434 <div class='encounter-summary-column'>
435 <?php if ($GLOBALS['enable_amc_prompting']) { ?>
436 <div style='float:right;margin-right:25px;border-style:solid;border-width:1px;'>
437 <div style='float:left;margin:5px 5px 5px 5px;'>
438 <table>
439 <tr>
440 <td>
441 <?php // Display the education resource checkbox (AMC prompting)
442 $itemAMC = amcCollect("patient_edu_amc", $pid, 'form_encounter', $encounter);
444 <?php if (!(empty($itemAMC))) { ?>
445 <input type="checkbox" id="prov_edu_res" checked>
446 <?php } else { ?>
447 <input type="checkbox" id="prov_edu_res">
448 <?php } ?>
449 </td>
450 <td>
451 <span class="text"><?php echo xl('Provided Education Resource(s)?') ?></span>
452 </td>
453 </tr>
454 <tr>
455 <td>
456 <?php // Display the Provided Clinical Summary checkbox (AMC prompting)
457 $itemAMC = amcCollect("provide_sum_pat_amc", $pid, 'form_encounter', $encounter);
459 <?php if (!(empty($itemAMC))) { ?>
460 <input type="checkbox" id="provide_sum_pat_flag" checked>
461 <?php } else { ?>
462 <input type="checkbox" id="provide_sum_pat_flag">
463 <?php } ?>
464 </td>
465 <td>
466 <span class="text"><?php echo xl('Provided Clinical Summary?') ?></span>
467 </td>
468 </tr>
469 <?php // Display the medication reconciliation checkboxes (AMC prompting)
470 $itemAMC = amcCollect("med_reconc_amc", $pid, 'form_encounter', $encounter);
472 <?php if (!(empty($itemAMC))) { ?>
473 <tr>
474 <td>
475 <input type="checkbox" id="trans_trand_care" checked>
476 </td>
477 <td>
478 <span class="text"><?php echo xl('Transition/Transfer of Care?') ?></span>
479 </td>
480 </tr>
481 </table>
482 <table style="margin-left:2em;">
483 <tr>
484 <td>
485 <?php if (!(empty($itemAMC['date_completed']))) { ?>
486 <input type="checkbox" id="med_reconc_perf" checked>
487 <?php } else { ?>
488 <input type="checkbox" id="med_reconc_perf">
489 <?php } ?>
490 </td>
491 <td>
492 <span class="text"><?php echo xl('Medication Reconciliation Performed?') ?></span>
493 </td>
494 </tr>
495 <tr>
496 <td>
497 <?php if (!(empty($itemAMC['soc_provided']))) { ?>
498 <input type="checkbox" id="soc_provided" checked>
499 <?php } else { ?>
500 <input type="checkbox" id="soc_provided">
501 <?php } ?>
502 </td>
503 <td>
504 <span class="text"><?php echo xl('Summary Of Care Provided?') ?></span>
505 </td>
506 </tr>
507 </table>
508 <?php } else { ?>
509 <tr>
510 <td>
511 <input type="checkbox" id="trans_trand_care">
512 </td>
513 <td>
514 <span class="text"><?php echo xl('Transition/Transfer of Care?') ?></span>
515 </td>
516 </tr>
517 </table>
518 <table style="margin-left:2em;">
519 <tr>
520 <td>
521 <input type="checkbox" id="med_reconc_perf" DISABLED>
522 </td>
523 <td>
524 <span class="text"><?php echo xl('Medication Reconciliation Performed?') ?></span>
525 </td>
526 </tr>
527 <tr>
528 <td>
529 <input type="checkbox" id="soc_provided" DISABLED>
530 </td>
531 <td>
532 <span class="text"><?php echo xl('Summary of Care Provided?') ?></span>
533 </td>
534 </tr>
535 </table>
536 <?php } ?>
537 </div>
538 </div>
539 <?php } ?>
540 </div>
542 </div>
544 <!-- Get the documents tagged to this encounter and display the links and notes as the tooltip -->
545 <?php
546 if($attendant_type == 'pid'){
547 $docs_list = getDocumentsByEncounter($pid,$_SESSION['encounter']);
548 } else {
549 // already doesn't exist document for therapy groups
550 $docs_list = array();
552 if(count($docs_list) > 0 ) {
554 <div class='enc_docs'>
555 <span class="bold"><?php echo xlt("Document(s)"); ?>:</span>
556 <?php
557 $doc = new C_Document();
558 foreach ($docs_list as $doc_iter) {
559 $doc_url = $doc->_tpl_vars[CURRENT_ACTION]. "&view&patient_id=".attr($pid)."&document_id=" . attr($doc_iter[id]) . "&";
560 // Get notes for this document.
561 $queryString = "SELECT GROUP_CONCAT(note ORDER BY date DESC SEPARATOR '|') AS docNotes, GROUP_CONCAT(date ORDER BY date DESC SEPARATOR '|') AS docDates
562 FROM notes WHERE foreign_id = ? GROUP BY foreign_id";
563 $noteData = sqlQuery($queryString,array($doc_iter[id]));
564 $note = '';
565 if ( $noteData ) {
566 $notes = array();
567 $notes = explode("|",$noteData['docNotes']);
568 $dates = explode("|", $noteData['docDates']);
569 for ( $i = 0 ; $i < count($notes) ; $i++ )
570 $note .= oeFormatShortDate(date('Y-m-d', strtotime($dates[$i]))) . " : " . $notes[$i] . "\n";
573 <br>
574 <a href="<?php echo $doc_url;?>" style="font-size:small;" onsubmit="return top.restoreSession()"><?php echo oeFormatShortDate($doc_iter[docdate]) . ": " . text(basename($doc_iter[url]));?></a>
575 <?php if($note != '') {?>
576 <a href="javascript:void(0);" title="<?php echo attr($note);?>"><img src="../../../images/info.png"/></a>
577 <?php }?>
578 <?php } ?>
579 </div>
580 <?php } ?>
581 <br/>
583 <?php
585 if ( ($pass_sens_squad) && ($result = getFormByEncounter($attendant_id, $encounter, "id, date, form_id, form_name, formdir, user, deleted")) ) {
586 echo "<table width='100%' id='partable'>";
587 $divnos=1;
588 foreach ($result as $iter) {
589 $formdir = $iter['formdir'];
591 // skip forms whose 'deleted' flag is set to 1
592 if ($iter['deleted'] == 1) continue;
594 $aco_spec = false;
596 if (substr($formdir,0,3) == 'LBF') {
597 // Skip LBF forms that we are not authorized to see.
598 $lrow = sqlQuery("SELECT * FROM list_options WHERE " .
599 "list_id = 'lbfnames' AND option_id = ? AND activity = 1",
600 array($formdir));
601 if (!empty($lrow)) {
602 $jobj = json_decode($lrow['notes'], true);
603 if (!empty($jobj['aco'])) {
604 $aco_spec = explode('|', $jobj['aco']);
605 if (!acl_check($aco_spec[0], $aco_spec[1])) continue;
609 else {
610 // Skip non-LBF forms that we are not authorized to see.
611 $tmp = getRegistryEntryByDirectory($formdir, 'aco_spec');
612 if (!empty($tmp['aco_spec'])) {
613 $aco_spec = explode('|', $tmp['aco_spec']);
614 if (!acl_check($aco_spec[0], $aco_spec[1])) continue;
618 // $form_info = getFormInfoById($iter['id']);
619 if (strtolower(substr($iter['form_name'],0,5)) == 'camos') {
620 //CAMOS generates links from report.php and these links should
621 //be clickable without causing view.php to come up unexpectedly.
622 //I feel that the JQuery code in this file leading to a click
623 //on the report.php content to bring up view.php steps on a
624 //form's autonomy to generate it's own html content in it's report
625 //but until any other form has a problem with this, I will just
626 //make an exception here for CAMOS and allow it to carry out this
627 //functionality for all other forms. --Mark
628 echo '<tr title="' . xl('Edit form') . '" '.
629 'id="'.$formdir.'~'.$iter['form_id'].'">';
630 } else {
631 echo '<tr title="' . xl('Edit form') . '" '.
632 'id="'.$formdir.'~'.$iter['form_id'].'" class="text onerow">';
635 $acl_groups = acl_check("groups","glog",false, 'write') ? true : false;
636 $user = getNameFromUsername($iter['user']);
638 $form_name = ($formdir == 'newpatient') ? xl('Patient Encounter') : xl_form_title($iter['form_name']);
640 // Create the ESign instance for this form
641 $esign = $esignApi->createFormESign( $iter['id'], $formdir, $encounter );
642 echo "<tr>";
643 echo "<td style='border-bottom:1px solid'>";
644 // a link to edit the form
645 echo "<div class='form_header_controls'>";
647 // If the form is locked, it is no longer editable
648 if ($esign->isLocked()) {
649 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>";
650 } else {
651 if ((!$aco_spec || acl_check($aco_spec[0], $aco_spec[1], '' , 'write') AND $is_group == 0)
652 OR (((!$aco_spec || acl_check($aco_spec[0], $aco_spec[1], '' , 'write')) AND $is_group AND acl_check("groups","glog",false, 'write')))) {
653 echo "<a class='css_button_small form-edit-button' id='form-edit-button-".attr($formdir)."-".attr($iter['id'])."' target='".
654 "_parent" .
655 "' href='$rootdir/patient_file/encounter/view_form.php?" .
656 "formname=" . attr($formdir) . "&id=" . attr($iter['form_id']) .
657 "' onclick='top.restoreSession()'>";
658 echo "<span>" . xlt('Edit') . "</span></a>";
662 if ( ($esign->isButtonViewable() AND $is_group == 0) OR ($esign->isButtonViewable() AND $is_group AND acl_check("groups","glog",false, 'write'))) {
663 if (!$aco_spec || acl_check($aco_spec[0], $aco_spec[1], '' , 'write')) {
664 echo $esign->buttonHtml();
668 if (acl_check('admin', 'super') ) {
669 if ( $formdir != 'newpatient' && $formdir != 'newGroupEncounter') {
670 // a link to delete the form from the encounter
671 echo "<a target='_parent'" .
672 " href='$rootdir/patient_file/encounter/delete_form.php?" .
673 "formname=" . $formdir .
674 "&id=" . $iter['id'] .
675 "&encounter=". $encounter.
676 "&pid=".$pid.
677 "' class='css_button_small' title='" . xl('Delete this form') . "' onclick='top.restoreSession()'><span>" . xl('Delete') . "</span></a>";
678 } else {
679 ?><a href='javascript:;' class='css_button_small' style='color:gray'><span><?php xl('Delete','e'); ?></span></a><?php
683 echo "<div class='form_header'>";
685 // Figure out the correct author (encounter authors are the '$providerNameRes', while other
686 // form authors are the '$user['fname'] . " " . $user['lname']').
687 if ($formdir == 'newpatient') {
688 $form_author = $providerNameRes;
690 else {
691 $form_author = $user['fname'] . " " . $user['lname'];
693 echo "<a href='#' onclick='divtoggle(\"spanid_$divnos\",\"divid_$divnos\");' class='small' id='aid_$divnos'><b>$form_name</b> <span class='text'>". xl('by')." ". htmlspecialchars( $form_author ) . "</span> (<span id=spanid_$divnos class=\"indicator\">" . xl('Collapse') . "</span>)</a></div>";
695 echo "</td>\n";
696 echo "</tr>";
697 echo "<tr>";
698 echo "<td valign='top' class='formrow'><div class='tab' id='divid_$divnos' style='display:block'>";
700 // Use the form's report.php for display. Forms with names starting with LBF
701 // are list-based forms sharing a single collection of code.
703 if (substr($formdir,0,3) == 'LBF') {
704 include_once($GLOBALS['incdir'] . "/forms/LBF/report.php");
706 call_user_func("lbf_report", $attendant_id, $encounter, 2, $iter['form_id'], $formdir, true);
708 else {
709 include_once($GLOBALS['incdir'] . "/forms/$formdir/report.php");
710 call_user_func($formdir . "_report", $attendant_id, $encounter, 2, $iter['form_id']);
713 if ( $esign->isLogViewable() ) {
714 $esign->renderLog();
717 echo "</div></td></tr>";
718 $divnos=$divnos+1;
720 echo "</table>";
722 if (!$pass_sens_squad) {
723 echo xlt("Not authorized to view this encounter");
727 </div> <!-- end large encounter_forms DIV -->
728 </body>
729 </html>