Removed athletic_team code.
[openemr.git] / interface / patient_file / encounter / forms.php
blob666757f88e8f2406bb73fd7b931d755e23d275f3
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/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");
19 <html>
21 <head>
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" />
38 <?php
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">
50 <?php } ?>
52 <script type="text/javascript">
53 $.noConflict();
54 jQuery(document).ready( function($) {
55 var formConfig = <?php echo $esignApi->formConfigToJson(); ?>;
56 $(".esign-button-form").esign(
57 formConfig,
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 );
68 });
73 var encounterConfig = <?php echo $esignApi->encounterConfigToJson(); ?>;
74 $(".esign-button-encounter").esign(
75 encounterConfig,
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 );
93 });
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') ) {
104 var mode = "add";
106 else {
107 var mode = "remove";
109 top.restoreSession();
110 $.post( "../../../library/ajax/amc_misc_data.php",
111 { amc_id: "patient_edu_amc",
112 complete: true,
113 mode: mode,
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') ) {
123 var mode = "add";
125 else {
126 var mode = "remove";
128 top.restoreSession();
129 $.post( "../../../library/ajax/amc_misc_data.php",
130 { amc_id: "provide_sum_pat_amc",
131 complete: true,
132 mode: mode,
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') ) {
142 var mode = "add";
143 // Enable the reconciliation checkbox
144 $("#med_reconc_perf").removeAttr("disabled");
146 else {
147 var mode = "remove";
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",
155 complete: false,
156 mode: mode,
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";
168 else {
169 var mode = "uncomplete";
171 top.restoreSession();
172 $.post( "../../../library/ajax/amc_misc_data.php",
173 { amc_id: "med_reconc_amc",
174 complete: true,
175 mode: mode,
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];
190 <?php else: ?>
191 top.Main.location.href = "<?php echo $rootdir; ?>/patient_file/encounter/view_form.php?formname="+parts[0]+"&id="+parts[1];
192 <?php endif; ?>
196 // Process click on Delete link.
197 function deleteme() {
198 dlgopen('../deleter.php?encounterid=<?php echo $encounter; ?>', '_blank', 500, 450);
199 return false;
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();
207 <?php } else { ?>
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';
211 <?php } ?>
214 </script>
216 <script language="javascript">
217 function expandcollapse(atr){
218 if(atr == "expand") {
219 for(i=1;i<15;i++){
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'); ?>";
228 else {
229 for(i=1;i<15;i++){
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'); ?>";
248 else {
249 ele.style.display = "block";
250 text.innerHTML = "<?php xl('Collapse','e'); ?>";
253 </script>
255 <style type="text/css">
256 div.tab {
257 min-height: 50px;
258 padding:8px;
261 div.form_header_controls {
262 float:left;margin-bottom:2px;
265 div.form_header {
266 float:left;
267 margin-left:6px;
270 .encounter-summary-container {
271 float:left;
272 width:100%;
275 .encounter-summary-column {
276 width: 33.3%;
277 float:left;
278 display:inline;
279 margin-top:10px;
281 </style>
283 </head>
284 <?php
285 $hide=1;
286 require_once("$incdir/patient_file/encounter/new_form.php");
288 <body class="body_top">
290 <div id="encounter_forms">
293 <?php
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'>
302 <div>
303 <span class="title"><?php echo oeFormatShortDate($encounter_date) . " " . xl("Encounter"); ?> </span>
304 <?php
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;
324 </div>
325 <div style='margin-top:8px;'>
326 <?php
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>
335 <?php } ?>
336 &nbsp;&nbsp;&nbsp;<a href="#" onClick='expandcollapse("expand");' style="font-size:80%;"><?php xl('Expand All','e'); ?></a>
337 &nbsp;&nbsp;&nbsp;<a style="font-size:80%;" href="#" onClick='expandcollapse("collapse");'><?php xl('Collapse All','e'); ?></a>
338 </div>
339 </div>
341 <div class='encounter-summary-column'>
342 <?php if ( $esign->isLogViewable() ) {
343 $esign->renderLog();
344 } ?>
345 </div>
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;'>
351 <table>
352 <tr>
353 <td>
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>
359 <?php } else { ?>
360 <input type="checkbox" id="prov_edu_res">
361 <?php } ?>
362 </td>
363 <td>
364 <span class="text"><?php echo xl('Provided Education Resource(s)?') ?></span>
365 </td>
366 </tr>
367 <tr>
368 <td>
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>
374 <?php } else { ?>
375 <input type="checkbox" id="provide_sum_pat_flag">
376 <?php } ?>
377 </td>
378 <td>
379 <span class="text"><?php echo xl('Provided Clinical Summary?') ?></span>
380 </td>
381 </tr>
382 <?php // Display the medication reconciliation checkboxes (AMC prompting)
383 $itemAMC = amcCollect("med_reconc_amc", $pid, 'form_encounter', $encounter);
385 <?php if (!(empty($itemAMC))) { ?>
386 <tr>
387 <td>
388 <input type="checkbox" id="trans_trand_care" checked>
389 </td>
390 <td>
391 <span class="text"><?php echo xl('Transition/Transfer of Care?') ?></span>
392 </td>
393 </tr>
394 </table>
395 <table style="margin-left:2em;">
396 <tr>
397 <td>
398 <?php if (!(empty($itemAMC['date_completed']))) { ?>
399 <input type="checkbox" id="med_reconc_perf" checked>
400 <?php } else { ?>
401 <input type="checkbox" id="med_reconc_perf">
402 <?php } ?>
403 </td>
404 <td>
405 <span class="text"><?php echo xl('Medication Reconciliation Performed?') ?></span>
406 </td>
407 </tr>
408 </table>
409 <?php } else { ?>
410 <tr>
411 <td>
412 <input type="checkbox" id="trans_trand_care">
413 </td>
414 <td>
415 <span class="text"><?php echo xl('Transition/Transfer of Care?') ?></span>
416 </td>
417 </tr>
418 </table>
419 <table style="margin-left:2em;">
420 <tr>
421 <td>
422 <input type="checkbox" id="med_reconc_perf" DISABLED>
423 </td>
424 <td>
425 <span class="text"><?php echo xl('Medication Reconciliation Performed?') ?></span>
426 </td>
427 </tr>
428 </table>
429 <?php } ?>
430 </div>
431 </div>
432 <?php } ?>
433 </div>
435 </div>
437 <!-- Get the documents tagged to this encounter and display the links and notes as the tooltip -->
438 <?php
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>
444 <?php
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]));
452 $note = '';
453 if ( $noteData ) {
454 $notes = array();
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";
461 <br>
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>
463 <?php } ?>
464 </div>
465 <?php } ?>
466 <br/>
468 <?php
469 if ($result = getFormByEncounter($pid, $encounter, "id, date, form_id, form_name, formdir, user, deleted")) {
470 echo "<table width='100%' id='partable'>";
471 $divnos=1;
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'))) ;
482 else continue;
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'].'">';
496 } else {
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 );
506 echo "<tr>";
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>";
514 } else {
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
530 echo "<a target='".
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.
536 "&pid=".$pid.
537 "' class='css_button_small' title='" . xl('Delete this form') . "' onclick='top.restoreSession()'><span>" . xl('Delete') . "</span></a>";
538 } else {
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;
550 else {
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>";
555 echo "</td>\n";
556 echo "</tr>";
557 echo "<tr>";
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);
567 else {
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() ) {
573 $esign->renderLog();
576 echo "</div></td></tr>";
577 $divnos=$divnos+1;
579 echo "</table>";
583 </div> <!-- end large encounter_forms DIV -->
584 </body>
586 </html>