Syntax fixes - static methods, call by reference and undefined variables
[openemr.git] / interface / patient_file / encounter / forms.php
blob6ee18061c81869fdfff55f517fe2f294391ada79
1 <?php
2 // This program is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU General Public License
4 // as published by the Free Software Foundation; either version 2
5 // of the License, or (at your option) any later version.
7 require_once("../../globals.php");
8 require_once("$srcdir/forms.inc");
9 require_once("$srcdir/calendar.inc");
10 require_once("$srcdir/acl.inc");
11 require_once("$srcdir/formatting.inc.php");
12 require_once("$srcdir/patient.inc");
13 require_once("$srcdir/amc.php");
15 <html>
17 <head>
18 <?php html_header_show();?>
19 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
21 <!-- supporting javascript code -->
22 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery.js"></script>
24 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/dialog.js"></script>
28 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
29 <link rel="stylesheet" type="text/css" href="../../../library/js/fancybox/jquery.fancybox-1.2.6.css" media="screen" />
30 <style type="text/css">@import url(../../../library/dynarch_calendar.css);</style>
31 <script type="text/javascript" src="../../../library/textformat.js"></script>
32 <script type="text/javascript" src="../../../library/dynarch_calendar.js"></script>
33 <?php include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?>
34 <script type="text/javascript" src="../../../library/dynarch_calendar_setup.js"></script>
35 <script type="text/javascript" src="../../../library/dialog.js"></script>
36 <script type="text/javascript" src="../../../library/js/jquery.1.3.2.js"></script>
37 <script type="text/javascript" src="../../../library/js/common.js"></script>
38 <script type="text/javascript" src="../../../library/js/fancybox/jquery.fancybox-1.2.6.js"></script>
40 <script language="JavaScript">
42 // Process click on Delete link.
43 function deleteme() {
44 dlgopen('../deleter.php?encounterid=<?php echo $encounter; ?>', '_blank', 500, 450);
45 return false;
48 // Called by the deleter.php window on a successful delete.
49 function imdeleted(EncounterId) {
50 <?php if ($GLOBALS['concurrent_layout']) { ?>
51 top.window.parent.left_nav.removeOptionSelected(EncounterId);
52 top.window.parent.left_nav.clearEncounter();
53 <?php } else { ?>
54 top.restoreSession();
55 top.Title.location.href = '../patient_file/encounter/encounter_title.php';
56 top.Main.location.href = '../patient_file/encounter/patient_encounter.php?mode=new';
57 <?php } ?>
60 </script>
62 <script language="javascript">
63 function expandcollapse(atr){
64 if(atr == "expand") {
65 for(i=1;i<15;i++){
66 var mydivid="divid_"+i;var myspanid="spanid_"+i;
67 var ele = document.getElementById(mydivid); var text = document.getElementById(myspanid);
68 ele.style.display = "block";text.innerHTML = "<?php xl('Collapse','e'); ?>";
71 else {
72 for(i=1;i<15;i++){
73 var mydivid="divid_"+i;var myspanid="spanid_"+i;
74 var ele = document.getElementById(mydivid); var text = document.getElementById(myspanid);
75 ele.style.display = "none"; text.innerHTML = "<?php xl('Expand','e'); ?>";
81 function divtoggle(spanid, divid) {
82 var ele = document.getElementById(divid);
83 var text = document.getElementById(spanid);
84 if(ele.style.display == "block") {
85 ele.style.display = "none";
86 text.innerHTML = "<?php xl('Expand','e'); ?>";
88 else {
89 ele.style.display = "block";
90 text.innerHTML = "<?php xl('Collapse','e'); ?>";
93 </script>
95 <style type="text/css">
96 div.tab {
97 min-height: 50px;
98 padding:8px;
101 div.form_header_controls {
102 float:left;margin-bottom:2px;
105 div.form_header {
106 float:left;
107 margin-left:6px;
109 </style>
111 </head>
112 <?php
113 $hide=1;
114 require_once("$incdir/patient_file/encounter/new_form.php");
116 <body class="body_top">
118 <div id="encounter_forms">
121 <?php
122 $dateres = getEncounterDateByEncounter($encounter);
123 $encounter_date = date("Y-m-d",strtotime($dateres["date"]));
124 $providerIDres = getProviderIdOfEncounter($encounter);
125 $providerNameRes = getProviderName($providerIDres);
128 <div style='float:left'>
129 <span class="title"><?php echo oeFormatShortDate($encounter_date) . " " . xl("Encounter"); ?> </span>
130 <?php
131 $auth_notes_a = acl_check('encounters', 'notes_a');
132 $auth_notes = acl_check('encounters', 'notes');
133 $auth_relaxed = acl_check('encounters', 'relaxed');
135 if (is_numeric($pid)) {
136 // Check for no access to the patient's squad.
137 $result = getPatientData($pid, "fname,lname,squad");
138 echo htmlspecialchars( xl('for','',' ',' ') . $result['fname'] . " " . $result['lname'] );
139 if ($result['squad'] && ! acl_check('squads', $result['squad'])) {
140 $auth_notes_a = $auth_notes = $auth_relaxed = 0;
142 // Check for no access to the encounter's sensitivity level.
143 $result = sqlQuery("SELECT sensitivity FROM form_encounter WHERE " .
144 "pid = '$pid' AND encounter = '$encounter' LIMIT 1");
145 if ($result['sensitivity'] && !acl_check('sensitivities', $result['sensitivity'])) {
146 $auth_notes_a = $auth_notes = $auth_relaxed = 0;
150 </div>
152 <div>
153 <div style='float:left;margin-left:10px'>
154 <?php if (acl_check('admin', 'super')) { ?>
155 <a href='toggledivs(this.id,this.id);' class='css_button' onclick='return deleteme()'><span><?php echo xl('Delete') ?></span></a>
156 <?php } ?>
157 &nbsp;&nbsp;&nbsp;<a href="#" onClick='expandcollapse("expand");' style="font-size:80%;"><?php xl('Expand All','e'); ?></a>
158 &nbsp;&nbsp;&nbsp;<a style="font-size:80%;" href="#" onClick='expandcollapse("collapse");'><?php xl('Collapse All','e'); ?></a>
159 </div>
161 <?php if ($GLOBALS['enable_amc_prompting']) { ?>
162 <div style='float:right;margin-right:25px;border-style:solid;border-width:1px;'>
163 <div style='float:left;margin:5px 5px 5px 5px;'>
164 <table>
165 <tr>
166 <td>
167 <?php // Display the education resource checkbox (AMC prompting)
168 $itemAMC = amcCollect("patient_edu_amc", $pid, 'form_encounter', $encounter);
170 <?php if (!(empty($itemAMC))) { ?>
171 <input type="checkbox" id="prov_edu_res" checked>
172 <?php } else { ?>
173 <input type="checkbox" id="prov_edu_res">
174 <?php } ?>
175 </td>
176 <td>
177 <span class="text"><?php echo xl('Provided Education Resource(s)?') ?></span>
178 </td>
179 </tr>
180 <tr>
181 <td>
182 <?php // Display the Provided Clinical Summary checkbox (AMC prompting)
183 $itemAMC = amcCollect("provide_sum_pat_amc", $pid, 'form_encounter', $encounter);
185 <?php if (!(empty($itemAMC))) { ?>
186 <input type="checkbox" id="provide_sum_pat_flag" checked>
187 <?php } else { ?>
188 <input type="checkbox" id="provide_sum_pat_flag">
189 <?php } ?>
190 </td>
191 <td>
192 <span class="text"><?php echo xl('Provided Clinical Summary?') ?></span>
193 </td>
194 </tr>
195 <?php // Display the medication reconciliation checkboxes (AMC prompting)
196 $itemAMC = amcCollect("med_reconc_amc", $pid, 'form_encounter', $encounter);
198 <?php if (!(empty($itemAMC))) { ?>
199 <tr>
200 <td>
201 <input type="checkbox" id="trans_trand_care" checked>
202 </td>
203 <td>
204 <span class="text"><?php echo xl('Transition/Transfer of Care?') ?></span>
205 </td>
206 </tr>
207 </table>
208 <table style="margin-left:2em;">
209 <tr>
210 <td>
211 <?php if (!(empty($itemAMC['date_completed']))) { ?>
212 <input type="checkbox" id="med_reconc_perf" checked>
213 <?php } else { ?>
214 <input type="checkbox" id="med_reconc_perf">
215 <?php } ?>
216 </td>
217 <td>
218 <span class="text"><?php echo xl('Medication Reconciliation Performed?') ?></span>
219 </td>
220 </tr>
221 </table>
222 <?php } else { ?>
223 <tr>
224 <td>
225 <input type="checkbox" id="trans_trand_care">
226 </td>
227 <td>
228 <span class="text"><?php echo xl('Transition/Transfer of Care?') ?></span>
229 </td>
230 </tr>
231 </table>
232 <table style="margin-left:2em;">
233 <tr>
234 <td>
235 <input type="checkbox" id="med_reconc_perf" DISABLED>
236 </td>
237 <td>
238 <span class="text"><?php echo xl('Medication Reconciliation Performed?') ?></span>
239 </td>
240 </tr>
241 </table>
242 <?php } ?>
243 </div>
244 </div>
245 <?php } ?>
246 </div>
247 <br/>
248 <br/>
250 <?php
251 if ($result = getFormByEncounter($pid, $encounter, "id, date, form_id, form_name, formdir, user, deleted")) {
252 echo "<table width='100%' id='partable'>";
253 $divnos=1;
254 foreach ($result as $iter) {
255 $formdir = $iter['formdir'];
257 // skip forms whose 'deleted' flag is set to 1
258 if ($iter['deleted'] == 1) continue;
260 // Skip forms that we are not authorized to see.
261 if (($auth_notes_a) ||
262 ($auth_notes && $iter['user'] == $_SESSION['authUser']) ||
263 ($auth_relaxed && ($formdir == 'sports_fitness' || $formdir == 'podiatry'))) ;
264 else continue;
266 // $form_info = getFormInfoById($iter['id']);
267 if (strtolower(substr($iter['form_name'],0,5)) == 'camos') {
268 //CAMOS generates links from report.php and these links should
269 //be clickable without causing view.php to come up unexpectedly.
270 //I feel that the JQuery code in this file leading to a click
271 //on the report.php content to bring up view.php steps on a
272 //form's autonomy to generate it's own html content in it's report
273 //but until any other form has a problem with this, I will just
274 //make an exception here for CAMOS and allow it to carry out this
275 //functionality for all other forms. --Mark
276 echo '<tr title="' . xl('Edit form') . '" '.
277 'id="'.$formdir.'~'.$iter['form_id'].'">';
278 } else {
279 echo '<tr title="' . xl('Edit form') . '" '.
280 'id="'.$formdir.'~'.$iter['form_id'].'" class="text onerow">';
282 $user = getNameFromUsername($iter['user']);
284 $form_name = ($formdir == 'newpatient') ? xl('Patient Encounter') : xl_form_title($iter['form_name']);
286 echo "<tr>";
287 echo "<td style='border-bottom:1px solid'>";
288 // a link to edit the form
289 echo "<div class='form_header_controls'>";
290 echo "<a target='".
291 ($GLOBALS['concurrent_layout'] ? "_parent" : "Main") .
292 "' href='$rootdir/patient_file/encounter/view_form.php?" .
293 "formname=" . $formdir . "&id=" . $iter['form_id'] .
294 "' onclick='top.restoreSession()' class='css_button_small'><span>" . xl('Edit') . "</span></a>";
296 if (acl_check('admin', 'super') ) {
297 if ( $formdir != 'newpatient') {
298 // a link to delete the form from the encounter
299 echo "<a target='".
300 ($GLOBALS['concurrent_layout'] ? "_parent" : "Main") .
301 "' href='$rootdir/patient_file/encounter/delete_form.php?" .
302 "formname=" . $formdir .
303 "&id=" . $iter['id'] .
304 "&encounter=". $encounter.
305 "&pid=".$pid.
306 "' class='css_button_small' title='" . xl('Delete this form') . "' onclick='top.restoreSession()'><span>" . xl('Delete') . "</span></a>";
307 } else {
308 ?><a href='javascript:;' class='css_button_small' style='color:gray'><span><?php xl('Delete','e'); ?></span></a><?php
312 echo "<div class='form_header'>";
314 // Figure out the correct author (encounter authors are the '$providerNameRes', while other
315 // form authors are the '$user['fname'] . " " . $user['lname']').
316 if ($formdir == 'newpatient') {
317 $form_author = $providerNameRes;
319 else {
320 $form_author = $user['fname'] . " " . $user['lname'];
322 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>";
324 echo "</td>\n";
325 echo "</tr>";
326 echo "<tr>";
327 echo "<td valign='top' class='formrow'><div class='tab' id='divid_$divnos' style='display:block'>";
329 // Use the form's report.php for display. Forms with names starting with LBF
330 // are list-based forms sharing a single collection of code.
332 if (substr($formdir,0,3) == 'LBF') {
333 include_once($GLOBALS['incdir'] . "/forms/LBF/report.php");
334 call_user_func("lbf_report", $pid, $encounter, 2, $iter['form_id'], $formdir);
336 else {
337 include_once($GLOBALS['incdir'] . "/forms/$formdir/report.php");
338 call_user_func($formdir . "_report", $pid, $encounter, 2, $iter['form_id']);
341 echo "</div></td></tr>";
342 $divnos=$divnos+1;
344 echo "</table>";
348 <?php if ($GLOBALS['athletic_team'] && $GLOBALS['concurrent_layout'] == 2) { ?>
349 <script language='JavaScript'>
350 // If this is the top frame then show the encounters list in the bottom frame.
351 // var n = parent.parent.left_nav;
352 var n = top.left_nav;
353 var nf = n.document.forms[0];
354 if (parent.window.name == 'RTop' && nf.cb_bot.checked) {
355 var othername = 'RBot';
356 n.setRadio(othername, 'ens');
357 n.loadFrame('ens1', othername, 'patient_file/history/encounters.php');
359 </script>
360 <?php } ?>
362 </div> <!-- end large encounter_forms DIV -->
363 </body>
365 <script language="javascript">
366 // jQuery stuff to make the page a little easier to use
368 $(document).ready(function(){
369 $(".onerow").mouseover(function() { $(this).toggleClass("highlight"); });
370 $(".onerow").mouseout(function() { $(this).toggleClass("highlight"); });
371 $(".onerow").click(function() { GotoForm(this); });
373 $("#prov_edu_res").click(function() {
374 if ( $('#prov_edu_res').attr('checked') ) {
375 var mode = "add";
377 else {
378 var mode = "remove";
380 top.restoreSession();
381 $.post( "../../../library/ajax/amc_misc_data.php",
382 { amc_id: "patient_edu_amc",
383 complete: true,
384 mode: mode,
385 patient_id: <?php echo htmlspecialchars($pid,ENT_NOQUOTES); ?>,
386 object_category: "form_encounter",
387 object_id: <?php echo htmlspecialchars($encounter,ENT_NOQUOTES); ?>
392 $("#provide_sum_pat_flag").click(function() {
393 if ( $('#provide_sum_pat_flag').attr('checked') ) {
394 var mode = "add";
396 else {
397 var mode = "remove";
399 top.restoreSession();
400 $.post( "../../../library/ajax/amc_misc_data.php",
401 { amc_id: "provide_sum_pat_amc",
402 complete: true,
403 mode: mode,
404 patient_id: <?php echo htmlspecialchars($pid,ENT_NOQUOTES); ?>,
405 object_category: "form_encounter",
406 object_id: <?php echo htmlspecialchars($encounter,ENT_NOQUOTES); ?>
411 $("#trans_trand_care").click(function() {
412 if ( $('#trans_trand_care').attr('checked') ) {
413 var mode = "add";
414 // Enable the reconciliation checkbox
415 $("#med_reconc_perf").removeAttr("disabled");
417 else {
418 var mode = "remove";
419 //Disable the reconciliation checkbox (also uncheck it if applicable)
420 $("#med_reconc_perf").attr("disabled", true);
421 $("#med_reconc_perf").removeAttr("checked");
423 top.restoreSession();
424 $.post( "../../../library/ajax/amc_misc_data.php",
425 { amc_id: "med_reconc_amc",
426 complete: false,
427 mode: mode,
428 patient_id: <?php echo htmlspecialchars($pid,ENT_NOQUOTES); ?>,
429 object_category: "form_encounter",
430 object_id: <?php echo htmlspecialchars($encounter,ENT_NOQUOTES); ?>
435 $("#med_reconc_perf").click(function() {
436 if ( $('#med_reconc_perf').attr('checked') ) {
437 var mode = "complete";
439 else {
440 var mode = "uncomplete";
442 top.restoreSession();
443 $.post( "../../../library/ajax/amc_misc_data.php",
444 { amc_id: "med_reconc_amc",
445 complete: true,
446 mode: mode,
447 patient_id: <?php echo htmlspecialchars($pid,ENT_NOQUOTES); ?>,
448 object_category: "form_encounter",
449 object_id: <?php echo htmlspecialchars($encounter,ENT_NOQUOTES); ?>
454 // $(".deleteme").click(function(evt) { deleteme(); evt.stopPropogation(); });
456 var GotoForm = function(obj) {
457 var parts = $(obj).attr("id").split("~");
458 top.restoreSession();
459 <?php if ($GLOBALS['concurrent_layout']): ?>
460 parent.location.href = "<?php echo $rootdir; ?>/patient_file/encounter/view_form.php?formname="+parts[0]+"&id="+parts[1];
461 <?php else: ?>
462 top.Main.location.href = "<?php echo $rootdir; ?>/patient_file/encounter/view_form.php?formname="+parts[0]+"&id="+parts[1];
463 <?php endif; ?>
467 </script>
469 </html>