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/calendar.inc");
11 require_once("$srcdir/acl.inc");
12 require_once("$srcdir/formatting.inc.php");
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");
21 <?php
html_header_show();?
>
22 <link rel
="stylesheet" href
="<?php echo $css_header;?>" type
="text/css">
23 <link rel
="stylesheet" type
="text/css" href
="../../../library/js/fancybox-1.3.4/jquery.fancybox-1.3.4.css" media
="screen" />
24 <style type
="text/css">@import
url(../../../library
/dynarch_calendar
.css
);</style
>
26 <!-- supporting javascript code
-->
27 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery-1.7.2.min.js"></script
>
28 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/dialog.js"></script
>
29 <script type
="text/javascript" src
="../../../library/textformat.js"></script
>
30 <script type
="text/javascript" src
="../../../library/dynarch_calendar.js"></script
>
31 <?php
include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?
>
32 <script type
="text/javascript" src
="../../../library/dynarch_calendar_setup.js"></script
>
33 <script type
="text/javascript" src
="../../../library/js/common.js"></script
>
34 <script type
="text/javascript" src
="../../../library/js/fancybox-1.3.4/jquery.fancybox-1.3.4.js"></script
>
35 <script src
="<?php echo $GLOBALS['webroot'] ?>/library/ESign/js/jquery.esign.js"></script
>
36 <link rel
="stylesheet" type
="text/css" href
="<?php echo $GLOBALS['webroot'] ?>/library/ESign/css/esign.css" />
38 $esignApi = new Api();
41 <?php
// include generic js support for graphing ?>
42 <script type
="text/javascript" src
="<?php echo $GLOBALS['web_root']?>/library/openflashchart/js/json/json2.js"></script
>
43 <script type
="text/javascript" src
="<?php echo $GLOBALS['web_root']?>/library/openflashchart/js/swfobject.js"></script
>
45 <?php
// if the track_anything form exists, then include the styling and js functions for graphing
46 if (file_exists(dirname(__FILE__
) . "/../../forms/track_anything/style.css")) { ?
>
47 <script type
="text/javascript" src
="<?php echo $GLOBALS['web_root']?>/interface/forms/track_anything/report.js"></script
>
48 <link rel
="stylesheet" href
="<?php echo $GLOBALS['web_root']?>/interface/forms/track_anything/style.css" type
="text/css">
51 <script type
="text/javascript">
52 $
(document
).ready( function() {
53 var formConfig
= <?php
echo $esignApi->formConfigToJson(); ?
>;
54 $
(".esign-button-form").esign(
57 afterFormSuccess
: function( response
) {
58 if ( response
.locked
) {
59 var editButtonId
= "form-edit-button-"+response
.formDir+
"-"+response
.formId
;
60 $
("#"+editButtonId
).replaceWith( response
.editButtonHtml
);
63 var logId
= "esign-signature-log-"+response
.formDir+
"-"+response
.formId
;
64 $
.post( formConfig
.logViewAction
, response
, function( html
) {
65 $
("#"+logId
).replaceWith( html
);
71 var encounterConfig
= <?php
echo $esignApi->encounterConfigToJson(); ?
>;
72 $
(".esign-button-encounter").esign(
75 afterFormSuccess
: function( response
) {
76 // If the response indicates a locked encounter, replace all
77 // form edit buttons with a "disabled" button, and "disable" left
78 // nav visit form links
79 if ( response
.locked
) {
80 // Lock the form edit buttons
81 $
(".form-edit-button").replaceWith( response
.editButtonHtml
);
82 // Disable the new-form capabilities in left nav
83 top
.window
.parent
.left_nav
.syncRadios();
84 // Disable the new-form capabilities in top nav of the encounter
85 $
(".encounter-form-category-li").remove();
88 var logId
= "esign-signature-log-encounter-"+response
.encounterId
;
89 $
.post( encounterConfig
.logViewAction
, response
, function( html
) {
90 $
("#"+logId
).replaceWith( html
);
97 // Process click on Delete link.
99 dlgopen('../deleter.php?encounterid=<?php echo $encounter; ?>', '_blank', 500, 450);
103 // Called by the deleter.php window on a successful delete.
104 function imdeleted(EncounterId
) {
105 <?php
if ($GLOBALS['concurrent_layout']) { ?
>
106 top
.window
.parent
.left_nav
.removeOptionSelected(EncounterId
);
107 top
.window
.parent
.left_nav
.clearEncounter();
109 top
.restoreSession();
110 top
.Title
.location
.href
= '../patient_file/encounter/encounter_title.php';
111 top
.Main
.location
.href
= '../patient_file/encounter/patient_encounter.php?mode=new';
117 <script language
="javascript">
118 function expandcollapse(atr
){
119 if(atr
== "expand") {
121 var mydivid
="divid_"+i
;var myspanid
="spanid_"+i
;
122 var ele
= document
.getElementById(mydivid
); var text
= document
.getElementById(myspanid
);
123 if (typeof(ele
) != 'undefined' && ele
!= null)
124 ele
.style
.display
= "block";
125 if (typeof(text
) != 'undefined' && text
!= null)
126 text
.innerHTML
= "<?php xl('Collapse','e'); ?>";
131 var mydivid
="divid_"+i
;var myspanid
="spanid_"+i
;
132 var ele
= document
.getElementById(mydivid
); var text
= document
.getElementById(myspanid
);
133 if (typeof(ele
) != 'undefined' && ele
!= null)
134 ele
.style
.display
= "none";
135 if (typeof(text
) != 'undefined' && text
!= null)
136 text
.innerHTML
= "<?php xl('Expand','e'); ?>";
142 function divtoggle(spanid
, divid
) {
143 var ele
= document
.getElementById(divid
);
144 var text
= document
.getElementById(spanid
);
145 if(ele
.style
.display
== "block") {
146 ele
.style
.display
= "none";
147 text
.innerHTML
= "<?php xl('Expand','e'); ?>";
150 ele
.style
.display
= "block";
151 text
.innerHTML
= "<?php xl('Collapse','e'); ?>";
156 <style type
="text/css">
162 div
.form_header_controls
{
163 float:left
;margin
-bottom
:2px
;
171 .encounter
-summary
-container
{
176 .encounter
-summary
-column
{
187 require_once("$incdir/patient_file/encounter/new_form.php");
189 <body
class="body_top">
191 <div id
="encounter_forms">
195 $dateres = getEncounterDateByEncounter($encounter);
196 $encounter_date = date("Y-m-d",strtotime($dateres["date"]));
197 $providerIDres = getProviderIdOfEncounter($encounter);
198 $providerNameRes = getProviderName($providerIDres);
201 <div
class='encounter-summary-container'>
202 <div
class='encounter-summary-column'>
204 <span
class="title"><?php
echo oeFormatShortDate($encounter_date) . " " . xl("Encounter"); ?
> </span
>
206 $auth_notes_a = acl_check('encounters', 'notes_a');
207 $auth_notes = acl_check('encounters', 'notes');
208 $auth_relaxed = acl_check('encounters', 'relaxed');
210 if (is_numeric($pid)) {
211 // Check for no access to the patient's squad.
212 $result = getPatientData($pid, "fname,lname,squad");
213 echo htmlspecialchars( xl('for','',' ',' ') . $result['fname'] . " " . $result['lname'] );
214 if ($result['squad'] && ! acl_check('squads', $result['squad'])) {
215 $auth_notes_a = $auth_notes = $auth_relaxed = 0;
217 // Check for no access to the encounter's sensitivity level.
218 $result = sqlQuery("SELECT sensitivity FROM form_encounter WHERE " .
219 "pid = '$pid' AND encounter = '$encounter' LIMIT 1");
220 if ($result['sensitivity'] && !acl_check('sensitivities', $result['sensitivity'])) {
221 $auth_notes_a = $auth_notes = $auth_relaxed = 0;
226 <div style
='margin-top:8px;'>
228 // ESign for entire encounter
229 $esign = $esignApi->createEncounterESign( $encounter );
230 if ( $esign->isButtonViewable() ) {
231 echo $esign->buttonHtml();
234 <?php
if (acl_check('admin', 'super')) { ?
>
235 <a href
='toggledivs(this.id,this.id);' class='css_button' onclick
='return deleteme()'><span
><?php
echo xl('Delete') ?
></span
></a
>
237  
; 
; 
;<a href
="#" onClick
='expandcollapse("expand");' style
="font-size:80%;"><?php
xl('Expand All','e'); ?
></a
>
238  
; 
; 
;<a style
="font-size:80%;" href
="#" onClick
='expandcollapse("collapse");'><?php
xl('Collapse All','e'); ?
></a
>
242 <div
class='encounter-summary-column'>
243 <?php
if ( $esign->isLogViewable() ) {
248 <div
class='encounter-summary-column'>
249 <?php
if ($GLOBALS['enable_amc_prompting']) { ?
>
250 <div style
='float:right;margin-right:25px;border-style:solid;border-width:1px;'>
251 <div style
='float:left;margin:5px 5px 5px 5px;'>
255 <?php
// Display the education resource checkbox (AMC prompting)
256 $itemAMC = amcCollect("patient_edu_amc", $pid, 'form_encounter', $encounter);
258 <?php
if (!(empty($itemAMC))) { ?
>
259 <input type
="checkbox" id
="prov_edu_res" checked
>
261 <input type
="checkbox" id
="prov_edu_res">
265 <span
class="text"><?php
echo xl('Provided Education Resource(s)?') ?
></span
>
270 <?php
// Display the Provided Clinical Summary checkbox (AMC prompting)
271 $itemAMC = amcCollect("provide_sum_pat_amc", $pid, 'form_encounter', $encounter);
273 <?php
if (!(empty($itemAMC))) { ?
>
274 <input type
="checkbox" id
="provide_sum_pat_flag" checked
>
276 <input type
="checkbox" id
="provide_sum_pat_flag">
280 <span
class="text"><?php
echo xl('Provided Clinical Summary?') ?
></span
>
283 <?php
// Display the medication reconciliation checkboxes (AMC prompting)
284 $itemAMC = amcCollect("med_reconc_amc", $pid, 'form_encounter', $encounter);
286 <?php
if (!(empty($itemAMC))) { ?
>
289 <input type
="checkbox" id
="trans_trand_care" checked
>
292 <span
class="text"><?php
echo xl('Transition/Transfer of Care?') ?
></span
>
296 <table style
="margin-left:2em;">
299 <?php
if (!(empty($itemAMC['date_completed']))) { ?
>
300 <input type
="checkbox" id
="med_reconc_perf" checked
>
302 <input type
="checkbox" id
="med_reconc_perf">
306 <span
class="text"><?php
echo xl('Medication Reconciliation Performed?') ?
></span
>
313 <input type
="checkbox" id
="trans_trand_care">
316 <span
class="text"><?php
echo xl('Transition/Transfer of Care?') ?
></span
>
320 <table style
="margin-left:2em;">
323 <input type
="checkbox" id
="med_reconc_perf" DISABLED
>
326 <span
class="text"><?php
echo xl('Medication Reconciliation Performed?') ?
></span
>
338 <!-- Get the documents tagged to this encounter
and display the links
and notes
as the tooltip
-->
340 $docs_list = getDocumentsByEncounter($pid,$_SESSION['encounter']);
341 if(count($docs_list) > 0 ) {
343 <div
class='enc_docs'>
344 <span
class="bold"><?php
echo xlt("Document(s)"); ?
>:</span
>
346 $doc = new C_Document();
347 foreach ($docs_list as $doc_iter) {
348 $doc_url = $doc->_tpl_vars
[CURRENT_ACTION
]. "&view&patient_id=".attr($pid)."&document_id=" . attr($doc_iter[id
]) . "&";
349 // Get notes for this document.
350 $queryString = "SELECT GROUP_CONCAT(note ORDER BY date DESC SEPARATOR '|') AS docNotes, GROUP_CONCAT(date ORDER BY date DESC SEPARATOR '|') AS docDates
351 FROM notes WHERE foreign_id = ? GROUP BY foreign_id";
352 $noteData = sqlQuery($queryString,array($doc_iter[id
]));
356 $notes = explode("|",$noteData['docNotes']);
357 $dates = explode("|", $noteData['docDates']);
358 for ( $i = 0 ; $i < count($notes) ; $i++
)
359 $note .= oeFormatShortDate(date('Y-m-d', strtotime($dates[$i]))) . " : " . $notes[$i] . "\n";
363 <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
>
370 if ($result = getFormByEncounter($pid, $encounter, "id, date, form_id, form_name, formdir, user, deleted")) {
371 echo "<table width='100%' id='partable'>";
373 foreach ($result as $iter) {
374 $formdir = $iter['formdir'];
376 // skip forms whose 'deleted' flag is set to 1
377 if ($iter['deleted'] == 1) continue;
379 // Skip forms that we are not authorized to see.
380 if (($auth_notes_a) ||
381 ($auth_notes && $iter['user'] == $_SESSION['authUser']) ||
382 ($auth_relaxed && ($formdir == 'sports_fitness' ||
$formdir == 'podiatry'))) ;
385 // $form_info = getFormInfoById($iter['id']);
386 if (strtolower(substr($iter['form_name'],0,5)) == 'camos') {
387 //CAMOS generates links from report.php and these links should
388 //be clickable without causing view.php to come up unexpectedly.
389 //I feel that the JQuery code in this file leading to a click
390 //on the report.php content to bring up view.php steps on a
391 //form's autonomy to generate it's own html content in it's report
392 //but until any other form has a problem with this, I will just
393 //make an exception here for CAMOS and allow it to carry out this
394 //functionality for all other forms. --Mark
395 echo '<tr title="' . xl('Edit form') . '" '.
396 'id="'.$formdir.'~'.$iter['form_id'].'">';
398 echo '<tr title="' . xl('Edit form') . '" '.
399 'id="'.$formdir.'~'.$iter['form_id'].'" class="text onerow">';
401 $user = getNameFromUsername($iter['user']);
403 $form_name = ($formdir == 'newpatient') ?
xl('Patient Encounter') : xl_form_title($iter['form_name']);
405 // Create the ESign instance for this form
406 $esign = $esignApi->createFormESign( $iter['id'], $formdir, $encounter );
408 echo "<td style='border-bottom:1px solid'>";
409 // a link to edit the form
410 echo "<div class='form_header_controls'>";
412 // If the form is locked, it is no longer editable
413 if ( $esign->isLocked() ) {
414 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>";
416 echo "<a class='css_button_small form-edit-button' id='form-edit-button-".attr($formdir)."-".attr($iter['id'])."' target='".
417 ($GLOBALS['concurrent_layout'] ?
"_parent" : "Main") .
418 "' href='$rootdir/patient_file/encounter/view_form.php?" .
419 "formname=" . attr($formdir) . "&id=" . attr($iter['form_id']) .
420 "' onclick='top.restoreSession()'>";
421 echo "<span>" . xlt('Edit') . "</span></a>";
424 if ( $esign->isButtonViewable() ) {
425 echo $esign->buttonHtml();
428 if (acl_check('admin', 'super') ) {
429 if ( $formdir != 'newpatient') {
430 // a link to delete the form from the encounter
432 ($GLOBALS['concurrent_layout'] ?
"_parent" : "Main") .
433 "' href='$rootdir/patient_file/encounter/delete_form.php?" .
434 "formname=" . $formdir .
435 "&id=" . $iter['id'] .
436 "&encounter=". $encounter.
438 "' class='css_button_small' title='" . xl('Delete this form') . "' onclick='top.restoreSession()'><span>" . xl('Delete') . "</span></a>";
440 ?
><a href
='javascript:;' class='css_button_small' style
='color:gray'><span
><?php
xl('Delete','e'); ?
></span
></a
><?php
444 echo "<div class='form_header'>";
446 // Figure out the correct author (encounter authors are the '$providerNameRes', while other
447 // form authors are the '$user['fname'] . " " . $user['lname']').
448 if ($formdir == 'newpatient') {
449 $form_author = $providerNameRes;
452 $form_author = $user['fname'] . " " . $user['lname'];
454 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>";
459 echo "<td valign='top' class='formrow'><div class='tab' id='divid_$divnos' style='display:block'>";
461 // Use the form's report.php for display. Forms with names starting with LBF
462 // are list-based forms sharing a single collection of code.
464 if (substr($formdir,0,3) == 'LBF') {
465 include_once($GLOBALS['incdir'] . "/forms/LBF/report.php");
466 call_user_func("lbf_report", $pid, $encounter, 2, $iter['form_id'], $formdir);
469 include_once($GLOBALS['incdir'] . "/forms/$formdir/report.php");
470 call_user_func($formdir . "_report", $pid, $encounter, 2, $iter['form_id']);
473 if ( $esign->isLogViewable() ) {
477 echo "</div></td></tr>";
484 <?php
if ($GLOBALS['athletic_team'] && $GLOBALS['concurrent_layout'] == 2) { ?
>
485 <script language
='JavaScript'>
486 // If this is the top frame then show the encounters list in the bottom frame.
487 // var n = parent.parent.left_nav;
488 var n
= top
.left_nav
;
489 var nf
= n
.document
.forms
[0];
490 if (parent
.window
.name
== 'RTop' && nf
.cb_bot
.checked
) {
491 var othername
= 'RBot';
492 n
.setRadio(othername
, 'ens');
493 n
.loadFrame('ens1', othername
, 'patient_file/history/encounters.php');
498 </div
> <!-- end large encounter_forms DIV
-->
501 <script language
="javascript">
502 // jQuery stuff to make the page a little easier to use
504 $
(document
).ready(function(){
505 $
(".onerow").mouseover(function() { $
(this
).toggleClass("highlight"); });
506 $
(".onerow").mouseout(function() { $
(this
).toggleClass("highlight"); });
507 $
(".onerow").click(function() { GotoForm(this
); });
509 $
("#prov_edu_res").click(function() {
510 if ( $
('#prov_edu_res').attr('checked') ) {
516 top
.restoreSession();
517 $
.post( "../../../library/ajax/amc_misc_data.php",
518 { amc_id
: "patient_edu_amc",
521 patient_id
: <?php
echo htmlspecialchars($pid,ENT_NOQUOTES
); ?
>,
522 object_category
: "form_encounter",
523 object_id
: <?php
echo htmlspecialchars($encounter,ENT_NOQUOTES
); ?
>
528 $
("#provide_sum_pat_flag").click(function() {
529 if ( $
('#provide_sum_pat_flag').attr('checked') ) {
535 top
.restoreSession();
536 $
.post( "../../../library/ajax/amc_misc_data.php",
537 { amc_id
: "provide_sum_pat_amc",
540 patient_id
: <?php
echo htmlspecialchars($pid,ENT_NOQUOTES
); ?
>,
541 object_category
: "form_encounter",
542 object_id
: <?php
echo htmlspecialchars($encounter,ENT_NOQUOTES
); ?
>
547 $
("#trans_trand_care").click(function() {
548 if ( $
('#trans_trand_care').attr('checked') ) {
550 // Enable the reconciliation checkbox
551 $
("#med_reconc_perf").removeAttr("disabled");
555 //Disable the reconciliation checkbox (also uncheck it if applicable)
556 $
("#med_reconc_perf").attr("disabled", true);
557 $
("#med_reconc_perf").removeAttr("checked");
559 top
.restoreSession();
560 $
.post( "../../../library/ajax/amc_misc_data.php",
561 { amc_id
: "med_reconc_amc",
564 patient_id
: <?php
echo htmlspecialchars($pid,ENT_NOQUOTES
); ?
>,
565 object_category
: "form_encounter",
566 object_id
: <?php
echo htmlspecialchars($encounter,ENT_NOQUOTES
); ?
>
571 $
("#med_reconc_perf").click(function() {
572 if ( $
('#med_reconc_perf').attr('checked') ) {
573 var mode
= "complete";
576 var mode
= "uncomplete";
578 top
.restoreSession();
579 $
.post( "../../../library/ajax/amc_misc_data.php",
580 { amc_id
: "med_reconc_amc",
583 patient_id
: <?php
echo htmlspecialchars($pid,ENT_NOQUOTES
); ?
>,
584 object_category
: "form_encounter",
585 object_id
: <?php
echo htmlspecialchars($encounter,ENT_NOQUOTES
); ?
>
590 // $(".deleteme").click(function(evt) { deleteme(); evt.stopPropogation(); });
592 var GotoForm
= function(obj
) {
593 var parts
= $
(obj
).attr("id").split("~");
594 top
.restoreSession();
595 <?php
if ($GLOBALS['concurrent_layout']): ?
>
596 parent
.location
.href
= "<?php echo $rootdir; ?>/patient_file/encounter/view_form.php?formname="+parts
[0]+
"&id="+parts
[1];
598 top
.Main
.location
.href
= "<?php echo $rootdir; ?>/patient_file/encounter/view_form.php?formname="+parts
[0]+
"&id="+parts
[1];