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/formdata.inc.php");
11 require_once("$srcdir/calendar.inc");
12 require_once("$srcdir/acl.inc");
13 require_once("$srcdir/formatting.inc.php");
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");
22 <?php
html_header_show();?
>
23 <link rel
="stylesheet" href
="<?php echo $css_header;?>" type
="text/css">
24 <link rel
="stylesheet" type
="text/css" href
="../../../library/js/fancybox-1.3.4/jquery.fancybox-1.3.4.css" media
="screen" />
25 <style type
="text/css">@import
url(../../../library
/dynarch_calendar
.css
);</style
>
27 <!-- supporting javascript code
-->
28 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery-1.7.2.min.js"></script
>
29 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/dialog.js"></script
>
30 <script type
="text/javascript" src
="../../../library/textformat.js"></script
>
31 <script type
="text/javascript" src
="../../../library/dynarch_calendar.js"></script
>
32 <?php
include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?
>
33 <script type
="text/javascript" src
="../../../library/dynarch_calendar_setup.js"></script
>
34 <script type
="text/javascript" src
="../../../library/js/common.js"></script
>
35 <script type
="text/javascript" src
="../../../library/js/fancybox-1.3.4/jquery.fancybox-1.3.4.js"></script
>
36 <script src
="<?php echo $GLOBALS['webroot'] ?>/library/ESign/js/jquery.esign.js"></script
>
37 <link rel
="stylesheet" type
="text/css" href
="<?php echo $GLOBALS['webroot'] ?>/library/ESign/css/esign.css" />
39 $esignApi = new Api();
42 <?php
// include generic js support for graphing ?>
43 <script type
="text/javascript" src
="<?php echo $GLOBALS['web_root']?>/library/openflashchart/js/json/json2.js"></script
>
44 <script type
="text/javascript" src
="<?php echo $GLOBALS['web_root']?>/library/openflashchart/js/swfobject.js"></script
>
46 <?php
// if the track_anything form exists, then include the styling and js functions for graphing
47 if (file_exists(dirname(__FILE__
) . "/../../forms/track_anything/style.css")) { ?
>
48 <script type
="text/javascript" src
="<?php echo $GLOBALS['web_root']?>/interface/forms/track_anything/report.js"></script
>
49 <link rel
="stylesheet" href
="<?php echo $GLOBALS['web_root']?>/interface/forms/track_anything/style.css" type
="text/css">
52 <script type
="text/javascript">
54 jQuery(document
).ready( function($
) {
55 var formConfig
= <?php
echo $esignApi->formConfigToJson(); ?
>;
56 $
(".esign-button-form").esign(
59 afterFormSuccess
: function( response
) {
60 if ( response
.locked
) {
61 var editButtonId
= "form-edit-button-"+response
.formDir+
"-"+response
.formId
;
62 $
("#"+editButtonId
).replaceWith( response
.editButtonHtml
);
65 var logId
= "esign-signature-log-"+response
.formDir+
"-"+response
.formId
;
66 $
.post( formConfig
.logViewAction
, response
, function( html
) {
67 $
("#"+logId
).replaceWith( html
);
73 var encounterConfig
= <?php
echo $esignApi->encounterConfigToJson(); ?
>;
74 $
(".esign-button-encounter").esign(
77 afterFormSuccess
: function( response
) {
78 // If the response indicates a locked encounter, replace all
79 // form edit buttons with a "disabled" button, and "disable" left
80 // nav visit form links
81 if ( response
.locked
) {
82 // Lock the form edit buttons
83 $
(".form-edit-button").replaceWith( response
.editButtonHtml
);
84 // Disable the new-form capabilities in left nav
85 top
.window
.parent
.left_nav
.syncRadios();
86 // Disable the new-form capabilities in top nav of the encounter
87 $
(".encounter-form-category-li").remove();
90 var logId
= "esign-signature-log-encounter-"+response
.encounterId
;
91 $
.post( encounterConfig
.logViewAction
, response
, function( html
) {
92 $
("#"+logId
).replaceWith( html
);
98 $
(".onerow").mouseover(function() { $
(this
).toggleClass("highlight"); });
99 $
(".onerow").mouseout(function() { $
(this
).toggleClass("highlight"); });
100 $
(".onerow").click(function() { GotoForm(this
); });
102 $
("#prov_edu_res").click(function() {
103 if ( $
('#prov_edu_res').attr('checked') ) {
109 top
.restoreSession();
110 $
.post( "../../../library/ajax/amc_misc_data.php",
111 { amc_id
: "patient_edu_amc",
114 patient_id
: <?php
echo htmlspecialchars($pid,ENT_NOQUOTES
); ?
>,
115 object_category
: "form_encounter",
116 object_id
: <?php
echo htmlspecialchars($encounter,ENT_NOQUOTES
); ?
>
121 $
("#provide_sum_pat_flag").click(function() {
122 if ( $
('#provide_sum_pat_flag').attr('checked') ) {
128 top
.restoreSession();
129 $
.post( "../../../library/ajax/amc_misc_data.php",
130 { amc_id
: "provide_sum_pat_amc",
133 patient_id
: <?php
echo htmlspecialchars($pid,ENT_NOQUOTES
); ?
>,
134 object_category
: "form_encounter",
135 object_id
: <?php
echo htmlspecialchars($encounter,ENT_NOQUOTES
); ?
>
140 $
("#trans_trand_care").click(function() {
141 if ( $
('#trans_trand_care').attr('checked') ) {
143 // Enable the reconciliation checkbox
144 $
("#med_reconc_perf").removeAttr("disabled");
148 //Disable the reconciliation checkbox (also uncheck it if applicable)
149 $
("#med_reconc_perf").attr("disabled", true);
150 $
("#med_reconc_perf").removeAttr("checked");
152 top
.restoreSession();
153 $
.post( "../../../library/ajax/amc_misc_data.php",
154 { amc_id
: "med_reconc_amc",
157 patient_id
: <?php
echo htmlspecialchars($pid,ENT_NOQUOTES
); ?
>,
158 object_category
: "form_encounter",
159 object_id
: <?php
echo htmlspecialchars($encounter,ENT_NOQUOTES
); ?
>
164 $
("#med_reconc_perf").click(function() {
165 if ( $
('#med_reconc_perf').attr('checked') ) {
166 var mode
= "complete";
169 var mode
= "uncomplete";
171 top
.restoreSession();
172 $
.post( "../../../library/ajax/amc_misc_data.php",
173 { amc_id
: "med_reconc_amc",
176 patient_id
: <?php
echo htmlspecialchars($pid,ENT_NOQUOTES
); ?
>,
177 object_category
: "form_encounter",
178 object_id
: <?php
echo htmlspecialchars($encounter,ENT_NOQUOTES
); ?
>
183 // $(".deleteme").click(function(evt) { deleteme(); evt.stopPropogation(); });
185 var GotoForm
= function(obj
) {
186 var parts
= $
(obj
).attr("id").split("~");
187 top
.restoreSession();
188 <?php
if ($GLOBALS['concurrent_layout']): ?
>
189 parent
.location
.href
= "<?php echo $rootdir; ?>/patient_file/encounter/view_form.php?formname="+parts
[0]+
"&id="+parts
[1];
191 top
.Main
.location
.href
= "<?php echo $rootdir; ?>/patient_file/encounter/view_form.php?formname="+parts
[0]+
"&id="+parts
[1];
196 // Process click on Delete link.
197 function deleteme() {
198 dlgopen('../deleter.php?encounterid=<?php echo $encounter; ?>', '_blank', 500, 450);
202 // Called by the deleter.php window on a successful delete.
203 function imdeleted(EncounterId
) {
204 <?php
if ($GLOBALS['concurrent_layout']) { ?
>
205 top
.window
.parent
.left_nav
.removeOptionSelected(EncounterId
);
206 top
.window
.parent
.left_nav
.clearEncounter();
208 top
.restoreSession();
209 top
.Title
.location
.href
= '../patient_file/encounter/encounter_title.php';
210 top
.Main
.location
.href
= '../patient_file/encounter/patient_encounter.php?mode=new';
216 <script language
="javascript">
217 function expandcollapse(atr
){
218 if(atr
== "expand") {
220 var mydivid
="divid_"+i
;var myspanid
="spanid_"+i
;
221 var ele
= document
.getElementById(mydivid
); var text
= document
.getElementById(myspanid
);
222 if (typeof(ele
) != 'undefined' && ele
!= null)
223 ele
.style
.display
= "block";
224 if (typeof(text
) != 'undefined' && text
!= null)
225 text
.innerHTML
= "<?php xl('Collapse','e'); ?>";
230 var mydivid
="divid_"+i
;var myspanid
="spanid_"+i
;
231 var ele
= document
.getElementById(mydivid
); var text
= document
.getElementById(myspanid
);
232 if (typeof(ele
) != 'undefined' && ele
!= null)
233 ele
.style
.display
= "none";
234 if (typeof(text
) != 'undefined' && text
!= null)
235 text
.innerHTML
= "<?php xl('Expand','e'); ?>";
241 function divtoggle(spanid
, divid
) {
242 var ele
= document
.getElementById(divid
);
243 var text
= document
.getElementById(spanid
);
244 if(ele
.style
.display
== "block") {
245 ele
.style
.display
= "none";
246 text
.innerHTML
= "<?php xl('Expand','e'); ?>";
249 ele
.style
.display
= "block";
250 text
.innerHTML
= "<?php xl('Collapse','e'); ?>";
255 <style type
="text/css">
261 div
.form_header_controls
{
262 float:left
;margin
-bottom
:2px
;
270 .encounter
-summary
-container
{
275 .encounter
-summary
-column
{
286 require_once("$incdir/patient_file/encounter/new_form.php");
288 <body
class="body_top">
290 <div id
="encounter_forms">
294 $dateres = getEncounterDateByEncounter($encounter);
295 $encounter_date = date("Y-m-d",strtotime($dateres["date"]));
296 $providerIDres = getProviderIdOfEncounter($encounter);
297 $providerNameRes = getProviderName($providerIDres);
300 <div
class='encounter-summary-container'>
301 <div
class='encounter-summary-column'>
303 <span
class="title"><?php
echo oeFormatShortDate($encounter_date) . " " . xl("Encounter"); ?
> </span
>
305 $auth_notes_a = acl_check('encounters', 'notes_a');
306 $auth_notes = acl_check('encounters', 'notes');
307 $auth_relaxed = acl_check('encounters', 'relaxed');
309 if (is_numeric($pid)) {
310 // Check for no access to the patient's squad.
311 $result = getPatientData($pid, "fname,lname,squad");
312 echo htmlspecialchars( xl('for','',' ',' ') . $result['fname'] . " " . $result['lname'] );
313 if ($result['squad'] && ! acl_check('squads', $result['squad'])) {
314 $auth_notes_a = $auth_notes = $auth_relaxed = 0;
316 // Check for no access to the encounter's sensitivity level.
317 $result = sqlQuery("SELECT sensitivity FROM form_encounter WHERE " .
318 "pid = '$pid' AND encounter = '$encounter' LIMIT 1");
319 if ($result['sensitivity'] && !acl_check('sensitivities', $result['sensitivity'])) {
320 $auth_notes_a = $auth_notes = $auth_relaxed = 0;
325 <div style
='margin-top:8px;'>
327 // ESign for entire encounter
328 $esign = $esignApi->createEncounterESign( $encounter );
329 if ( $esign->isButtonViewable() ) {
330 echo $esign->buttonHtml();
333 <?php
if (acl_check('admin', 'super')) { ?
>
334 <a href
='toggledivs(this.id,this.id);' class='css_button' onclick
='return deleteme()'><span
><?php
echo xl('Delete') ?
></span
></a
>
336  
; 
; 
;<a href
="#" onClick
='expandcollapse("expand");' style
="font-size:80%;"><?php
xl('Expand All','e'); ?
></a
>
337  
; 
; 
;<a style
="font-size:80%;" href
="#" onClick
='expandcollapse("collapse");'><?php
xl('Collapse All','e'); ?
></a
>
341 <div
class='encounter-summary-column'>
342 <?php
if ( $esign->isLogViewable() ) {
347 <div
class='encounter-summary-column'>
348 <?php
if ($GLOBALS['enable_amc_prompting']) { ?
>
349 <div style
='float:right;margin-right:25px;border-style:solid;border-width:1px;'>
350 <div style
='float:left;margin:5px 5px 5px 5px;'>
354 <?php
// Display the education resource checkbox (AMC prompting)
355 $itemAMC = amcCollect("patient_edu_amc", $pid, 'form_encounter', $encounter);
357 <?php
if (!(empty($itemAMC))) { ?
>
358 <input type
="checkbox" id
="prov_edu_res" checked
>
360 <input type
="checkbox" id
="prov_edu_res">
364 <span
class="text"><?php
echo xl('Provided Education Resource(s)?') ?
></span
>
369 <?php
// Display the Provided Clinical Summary checkbox (AMC prompting)
370 $itemAMC = amcCollect("provide_sum_pat_amc", $pid, 'form_encounter', $encounter);
372 <?php
if (!(empty($itemAMC))) { ?
>
373 <input type
="checkbox" id
="provide_sum_pat_flag" checked
>
375 <input type
="checkbox" id
="provide_sum_pat_flag">
379 <span
class="text"><?php
echo xl('Provided Clinical Summary?') ?
></span
>
382 <?php
// Display the medication reconciliation checkboxes (AMC prompting)
383 $itemAMC = amcCollect("med_reconc_amc", $pid, 'form_encounter', $encounter);
385 <?php
if (!(empty($itemAMC))) { ?
>
388 <input type
="checkbox" id
="trans_trand_care" checked
>
391 <span
class="text"><?php
echo xl('Transition/Transfer of Care?') ?
></span
>
395 <table style
="margin-left:2em;">
398 <?php
if (!(empty($itemAMC['date_completed']))) { ?
>
399 <input type
="checkbox" id
="med_reconc_perf" checked
>
401 <input type
="checkbox" id
="med_reconc_perf">
405 <span
class="text"><?php
echo xl('Medication Reconciliation Performed?') ?
></span
>
412 <input type
="checkbox" id
="trans_trand_care">
415 <span
class="text"><?php
echo xl('Transition/Transfer of Care?') ?
></span
>
419 <table style
="margin-left:2em;">
422 <input type
="checkbox" id
="med_reconc_perf" DISABLED
>
425 <span
class="text"><?php
echo xl('Medication Reconciliation Performed?') ?
></span
>
437 <!-- Get the documents tagged to this encounter
and display the links
and notes
as the tooltip
-->
439 $docs_list = getDocumentsByEncounter($pid,$_SESSION['encounter']);
440 if(count($docs_list) > 0 ) {
442 <div
class='enc_docs'>
443 <span
class="bold"><?php
echo xlt("Document(s)"); ?
>:</span
>
445 $doc = new C_Document();
446 foreach ($docs_list as $doc_iter) {
447 $doc_url = $doc->_tpl_vars
[CURRENT_ACTION
]. "&view&patient_id=".attr($pid)."&document_id=" . attr($doc_iter[id
]) . "&";
448 // Get notes for this document.
449 $queryString = "SELECT GROUP_CONCAT(note ORDER BY date DESC SEPARATOR '|') AS docNotes, GROUP_CONCAT(date ORDER BY date DESC SEPARATOR '|') AS docDates
450 FROM notes WHERE foreign_id = ? GROUP BY foreign_id";
451 $noteData = sqlQuery($queryString,array($doc_iter[id
]));
455 $notes = explode("|",$noteData['docNotes']);
456 $dates = explode("|", $noteData['docDates']);
457 for ( $i = 0 ; $i < count($notes) ; $i++
)
458 $note .= oeFormatShortDate(date('Y-m-d', strtotime($dates[$i]))) . " : " . $notes[$i] . "\n";
462 <a title
="<?php echo attr($note);?>" 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
>
469 if ($result = getFormByEncounter($pid, $encounter, "id, date, form_id, form_name, formdir, user, deleted")) {
470 echo "<table width='100%' id='partable'>";
472 foreach ($result as $iter) {
473 $formdir = $iter['formdir'];
475 // skip forms whose 'deleted' flag is set to 1
476 if ($iter['deleted'] == 1) continue;
478 // Skip forms that we are not authorized to see.
479 if (($auth_notes_a) ||
480 ($auth_notes && $iter['user'] == $_SESSION['authUser']) ||
481 ($auth_relaxed && ($formdir == 'sports_fitness' ||
$formdir == 'podiatry'))) ;
484 // $form_info = getFormInfoById($iter['id']);
485 if (strtolower(substr($iter['form_name'],0,5)) == 'camos') {
486 //CAMOS generates links from report.php and these links should
487 //be clickable without causing view.php to come up unexpectedly.
488 //I feel that the JQuery code in this file leading to a click
489 //on the report.php content to bring up view.php steps on a
490 //form's autonomy to generate it's own html content in it's report
491 //but until any other form has a problem with this, I will just
492 //make an exception here for CAMOS and allow it to carry out this
493 //functionality for all other forms. --Mark
494 echo '<tr title="' . xl('Edit form') . '" '.
495 'id="'.$formdir.'~'.$iter['form_id'].'">';
497 echo '<tr title="' . xl('Edit form') . '" '.
498 'id="'.$formdir.'~'.$iter['form_id'].'" class="text onerow">';
500 $user = getNameFromUsername($iter['user']);
502 $form_name = ($formdir == 'newpatient') ?
xl('Patient Encounter') : xl_form_title($iter['form_name']);
504 // Create the ESign instance for this form
505 $esign = $esignApi->createFormESign( $iter['id'], $formdir, $encounter );
507 echo "<td style='border-bottom:1px solid'>";
508 // a link to edit the form
509 echo "<div class='form_header_controls'>";
511 // If the form is locked, it is no longer editable
512 if ( $esign->isLocked() ) {
513 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>";
515 echo "<a class='css_button_small form-edit-button' id='form-edit-button-".attr($formdir)."-".attr($iter['id'])."' target='".
516 ($GLOBALS['concurrent_layout'] ?
"_parent" : "Main") .
517 "' href='$rootdir/patient_file/encounter/view_form.php?" .
518 "formname=" . attr($formdir) . "&id=" . attr($iter['form_id']) .
519 "' onclick='top.restoreSession()'>";
520 echo "<span>" . xlt('Edit') . "</span></a>";
523 if ( $esign->isButtonViewable() ) {
524 echo $esign->buttonHtml();
527 if (acl_check('admin', 'super') ) {
528 if ( $formdir != 'newpatient') {
529 // a link to delete the form from the encounter
531 ($GLOBALS['concurrent_layout'] ?
"_parent" : "Main") .
532 "' href='$rootdir/patient_file/encounter/delete_form.php?" .
533 "formname=" . $formdir .
534 "&id=" . $iter['id'] .
535 "&encounter=". $encounter.
537 "' class='css_button_small' title='" . xl('Delete this form') . "' onclick='top.restoreSession()'><span>" . xl('Delete') . "</span></a>";
539 ?
><a href
='javascript:;' class='css_button_small' style
='color:gray'><span
><?php
xl('Delete','e'); ?
></span
></a
><?php
543 echo "<div class='form_header'>";
545 // Figure out the correct author (encounter authors are the '$providerNameRes', while other
546 // form authors are the '$user['fname'] . " " . $user['lname']').
547 if ($formdir == 'newpatient') {
548 $form_author = $providerNameRes;
551 $form_author = $user['fname'] . " " . $user['lname'];
553 echo "<a href='#' onclick='divtoggle(\"spanid_$divnos\",\"divid_$divnos\");' class='small' id='aid_$divnos'><b>$form_name</b> <span class='text'>by " . htmlspecialchars( $form_author ) . "</span> (<span id=spanid_$divnos class=\"indicator\">" . xl('Collapse') . "</span>)</a></div>";
558 echo "<td valign='top' class='formrow'><div class='tab' id='divid_$divnos' style='display:block'>";
560 // Use the form's report.php for display. Forms with names starting with LBF
561 // are list-based forms sharing a single collection of code.
563 if (substr($formdir,0,3) == 'LBF') {
564 include_once($GLOBALS['incdir'] . "/forms/LBF/report.php");
565 call_user_func("lbf_report", $pid, $encounter, 2, $iter['form_id'], $formdir);
568 include_once($GLOBALS['incdir'] . "/forms/$formdir/report.php");
569 call_user_func($formdir . "_report", $pid, $encounter, 2, $iter['form_id']);
572 if ( $esign->isLogViewable() ) {
576 echo "</div></td></tr>";
583 </div
> <!-- end large encounter_forms DIV
-->