bug fix of encounter id sent to report.php function
[openemr.git] / interface / patient_file / encounter / forms.php
blob775153e1d267cf821354dda858b597fba7398468
1 <?php
2 include_once("../../globals.php");
3 include_once("$srcdir/forms.inc");
4 include_once("$srcdir/calendar.inc");
5 include_once("$srcdir/acl.inc");
6 ?>
7 <html>
9 <head>
10 <?php html_header_show();?>
11 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
13 <!-- supporting javascript code -->
14 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery.js"></script>
16 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/dialog.js"></script>
18 <script language="JavaScript">
20 // Process click on Delete link.
21 function deleteme() {
22 dlgopen('../deleter.php?encounterid=<?php echo $encounter; ?>', '_blank', 500, 450);
23 return false;
26 // Called by the deleter.php window on a successful delete.
27 function imdeleted() {
28 <?php if ($GLOBALS['concurrent_layout']) { ?>
29 parent.parent.left_nav.clearEncounter();
30 <?php } else { ?>
31 top.restoreSession();
32 top.Title.location.href = '../patient_file/encounter/encounter_title.php';
33 top.Main.location.href = '../patient_file/encounter/patient_encounter.php?mode=new';
34 <?php } ?>
37 </script>
39 </head>
41 <body class="body_top">
42 <div id="encounter_forms">
44 <span class="title"><?php xl('This Encounter','e'); ?></span>
45 <?php
46 $auth_notes_a = acl_check('encounters', 'notes_a');
47 $auth_notes = acl_check('encounters', 'notes');
48 $auth_relaxed = acl_check('encounters', 'relaxed');
50 if (is_numeric($pid)) {
51 // Check for no access to the patient's squad.
52 $result = getPatientData($pid, "fname,lname,squad");
53 echo xl('for','',' ',' ') . $result['fname'] . " " . $result['lname'];
54 if ($result['squad'] && ! acl_check('squads', $result['squad'])) {
55 $auth_notes_a = $auth_notes = $auth_relaxed = 0;
57 // Check for no access to the encounter's sensitivity level.
58 $result = sqlQuery("SELECT sensitivity FROM form_encounter WHERE " .
59 "pid = '$pid' AND encounter = '$encounter' LIMIT 1");
60 if ($result['sensitivity'] && !acl_check('sensitivities', $result['sensitivity'])) {
61 $auth_notes_a = $auth_notes = $auth_relaxed = 0;
65 echo ":";
66 if (acl_check('admin', 'super')) {
67 // echo "&nbsp;&nbsp;<a href='' onclick='return deleteme()' class='deleteme'>" .
68 echo "&nbsp;&nbsp;<a href='' onclick='return deleteme()'>" .
69 "<font class='more' style='color:red'>(" . xl('Delete') . ")</font></a>";
71 echo "<br>\n";
73 if ($result = getFormByEncounter($pid, $encounter, "id, date, form_id, form_name, formdir, user, deleted")) {
74 echo "<table>";
75 echo "<tr><th>" . xl('User') . "</th><th>" . xl('Form') . "</th><th>&nbsp;</th></tr>";
76 foreach ($result as $iter) {
77 $formdir = $iter['formdir'];
79 // skip forms whose 'deleted' flag is set to 1
80 if ($iter['deleted'] == 1) continue;
82 // Skip forms that we are not authorized to see.
83 if (($auth_notes_a) ||
84 ($auth_notes && $iter['user'] == $_SESSION['authUser']) ||
85 ($auth_relaxed && ($formdir == 'sports_fitness' || $formdir == 'podiatry'))) ;
86 else continue;
88 // $form_info = getFormInfoById($iter['id']);
89 if (strtolower(substr($iter['form_name'],0,5)) == 'camos') {
90 //CAMOS generates links from report.php and these links should
91 //be clickable without causing view.php to come up unexpectedly.
92 //I feel that the JQuery code in this file leading to a click
93 //on the report.php content to bring up view.php steps on a
94 //form's autonomy to generate it's own html content in it's report
95 //but until any other form has a problem with this, I will just
96 //make an exception here for CAMOS and allow it to carry out this
97 //functionality for all other forms. --Mark
98 echo '<tr title="' . xl('Edit form') . '" '.
99 'id="'.$formdir.'~'.$iter['form_id'].'">';
100 } else {
101 echo '<tr title="' . xl('Edit form') . '" '.
102 'id="'.$formdir.'~'.$iter['form_id'].'" class="text onerow">';
104 $user = getNameFromUsername($iter['user']);
106 $form_name = ($formdir == 'newpatient') ? xl('Patient Encounter') : xl_form_title($iter['form_name']);
108 echo "<td valign='top' class='bold formrow'>" .
109 $user['fname'] . " " . $user['lname'] . "</td>";
110 echo "<td valign='top' class='center formrow'>";
112 // a link to edit the form
113 echo "<a target='".
114 ($GLOBALS['concurrent_layout'] ? "_parent" : "Main") .
115 "' href='$rootdir/patient_file/encounter/view_form.php?" .
116 "formname=" . $formdir . "&id=" . $iter['form_id'] .
117 "' onclick='top.restoreSession()'>$form_name</a>";
119 if (acl_check('admin', 'super') && $formdir != 'newpatient') {
120 // a link to delete the form from the encounter
121 echo "<span class='small'> (<a target='".
122 ($GLOBALS['concurrent_layout'] ? "_parent" : "Main") .
123 "' href='$rootdir/patient_file/encounter/delete_form.php?" .
124 "formname=" . $formdir .
125 "&id=" . $iter['id'] .
126 "&encounter=". $encounter.
127 "&pid=".$pid.
128 "' class='small' title='" . xl('Delete this form') . "' onclick='top.restoreSession()'>" . xl('Delete') . "</a>)</span>";
131 echo "</td>\n" .
132 "<td valign='top' class='formrow' style='padding-left: 25px;'>";
134 // Use the form's report.php for display. Forms with names starting with LBF
135 // are list-based forms sharing a single collection of code.
137 if (substr($formdir,0,3) == 'LBF') {
138 include_once($GLOBALS['incdir'] . "/forms/LBF/report.php");
139 call_user_func("lbf_report", $pid, $encounter, 2, $iter['form_id'], $formdir);
141 else {
142 include_once($GLOBALS['incdir'] . "/forms/$formdir/report.php");
143 call_user_func($formdir . "_report", $pid, $encounter, 2, $iter['form_id']);
146 echo "</td></tr>";
148 echo "</table>";
152 <?php if ($GLOBALS['athletic_team'] && $GLOBALS['concurrent_layout'] == 2) { ?>
153 <script language='JavaScript'>
154 // If this is the top frame then show the encounters list in the bottom frame.
155 var n = parent.parent.left_nav;
156 var nf = n.document.forms[0];
157 if (parent.window.name == 'RTop' && nf.cb_bot.checked) {
158 var othername = 'RBot';
159 n.setRadio(othername, 'ens');
160 n.loadFrame('ens1', othername, 'patient_file/history/encounters.php');
162 </script>
163 <?php } ?>
165 </div> <!-- end large encounter_forms DIV -->
166 </body>
168 <script language="javascript">
169 // jQuery stuff to make the page a little easier to use
171 $(document).ready(function(){
172 $(".save").click(function() { top.restoreSession(); document.my_form.submit(); });
173 $(".dontsave").click(function() { location.href='<?php echo "$rootdir/patient_file/encounter/$returnurl";?>'; });
175 $(".onerow").mouseover(function() { $(this).toggleClass("highlight"); });
176 $(".onerow").mouseout(function() { $(this).toggleClass("highlight"); });
177 $(".onerow").click(function() { GotoForm(this); });
179 // $(".deleteme").click(function(evt) { deleteme(); evt.stopPropogation(); });
181 var GotoForm = function(obj) {
182 var parts = $(obj).attr("id").split("~");
183 top.restoreSession();
184 <?php if ($GLOBALS['concurrent_layout']): ?>
185 parent.location.href = "<?php echo $rootdir; ?>/patient_file/encounter/view_form.php?formname="+parts[0]+"&id="+parts[1];
186 <?php else: ?>
187 top.Main.location.href = "<?php echo $rootdir; ?>/patient_file/encounter/view_form.php?formname="+parts[0]+"&id="+parts[1];
188 <?php endif; ?>
192 </script>
194 </html>