CCR/CCD reporting module: added option to see the raw xml
[openemr.git] / interface / patient_file / encounter / forms.php
blob3ca26ac6d6f61a5b43fee83cc18ec4872779e412
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");
14 <html>
16 <head>
17 <?php html_header_show();?>
18 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
20 <!-- supporting javascript code -->
21 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery.js"></script>
23 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/dialog.js"></script>
27 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
28 <link rel="stylesheet" type="text/css" href="../../../library/js/fancybox/jquery.fancybox-1.2.6.css" media="screen" />
29 <style type="text/css">@import url(../../../library/dynarch_calendar.css);</style>
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/dialog.js"></script>
35 <script type="text/javascript" src="../../../library/js/jquery.1.3.2.js"></script>
36 <script type="text/javascript" src="../../../library/js/common.js"></script>
37 <script type="text/javascript" src="../../../library/js/fancybox/jquery.fancybox-1.2.6.js"></script>
39 <script language="JavaScript">
41 // Process click on Delete link.
42 function deleteme() {
43 dlgopen('../deleter.php?encounterid=<?php echo $encounter; ?>', '_blank', 500, 450);
44 return false;
47 // Called by the deleter.php window on a successful delete.
48 function imdeleted(EncounterId) {
49 <?php if ($GLOBALS['concurrent_layout']) { ?>
50 top.window.parent.left_nav.removeOptionSelected(EncounterId);
51 top.window.parent.left_nav.clearEncounter();
52 <?php } else { ?>
53 top.restoreSession();
54 top.Title.location.href = '../patient_file/encounter/encounter_title.php';
55 top.Main.location.href = '../patient_file/encounter/patient_encounter.php?mode=new';
56 <?php } ?>
59 </script>
61 <script language="javascript">
62 function expandcollapse(atr){
63 if(atr == "expand") {
64 for(i=1;i<15;i++){
65 var mydivid="divid_"+i;var myspanid="spanid_"+i;
66 var ele = document.getElementById(mydivid); var text = document.getElementById(myspanid);
67 ele.style.display = "block";text.innerHTML = "<?php xl('Collapse','e'); ?>";
70 else {
71 for(i=1;i<15;i++){
72 var mydivid="divid_"+i;var myspanid="spanid_"+i;
73 var ele = document.getElementById(mydivid); var text = document.getElementById(myspanid);
74 ele.style.display = "none"; text.innerHTML = "<?php xl('Expand','e'); ?>";
80 function divtoggle(spanid, divid) {
81 var ele = document.getElementById(divid);
82 var text = document.getElementById(spanid);
83 if(ele.style.display == "block") {
84 ele.style.display = "none";
85 text.innerHTML = "<?php xl('Expand','e'); ?>";
87 else {
88 ele.style.display = "block";
89 text.innerHTML = "<?php xl('Collapse','e'); ?>";
92 </script>
94 <style type="text/css">
95 div.tab {
96 min-height: 50px;
97 padding:8px;
100 div.form_header_controls {
101 float:left;margin-bottom:2px;
104 div.form_header {
105 float:left;
106 margin-left:6px;
108 </style>
110 </head>
111 <?php
112 $hide=1;
113 require_once("$incdir/patient_file/encounter/new_form.php");
115 <body class="body_top">
117 <div id="encounter_forms">
120 <?php
121 $dateres = getEncounterDateByEncounter($encounter);
122 $encounter_date = date("Y-m-d",strtotime($dateres["date"]));
125 <div style='float:left'>
126 <span class="title"><?php echo oeFormatShortDate($encounter_date) . " " . xl("Encounter"); ?> </span>
127 <?php
128 $auth_notes_a = acl_check('encounters', 'notes_a');
129 $auth_notes = acl_check('encounters', 'notes');
130 $auth_relaxed = acl_check('encounters', 'relaxed');
132 if (is_numeric($pid)) {
133 // Check for no access to the patient's squad.
134 $result = getPatientData($pid, "fname,lname,squad");
135 echo htmlspecialchars( xl('for','',' ',' ') . $result['fname'] . " " . $result['lname'] );
136 if ($result['squad'] && ! acl_check('squads', $result['squad'])) {
137 $auth_notes_a = $auth_notes = $auth_relaxed = 0;
139 // Check for no access to the encounter's sensitivity level.
140 $result = sqlQuery("SELECT sensitivity FROM form_encounter WHERE " .
141 "pid = '$pid' AND encounter = '$encounter' LIMIT 1");
142 if ($result['sensitivity'] && !acl_check('sensitivities', $result['sensitivity'])) {
143 $auth_notes_a = $auth_notes = $auth_relaxed = 0;
147 </div>
148 <div style='float:left;margin-left:10px'>
149 <?php if (acl_check('admin', 'super')) { ?>
150 <a href='toggledivs(this.id,this.id);' class='css_button' onclick='return deleteme()'><span><?php echo xl('Delete') ?></span></a>
151 &nbsp;&nbsp;&nbsp;<a href="#" onClick='expandcollapse("expand");' style="font-size:80%;"><?php xl('Expand All','e'); ?></a>
152 &nbsp;&nbsp;&nbsp;<a style="font-size:80%;" href="#" onClick='expandcollapse("collapse");'><?php xl('Collapse All','e'); ?></a>
153 <?php } ?>
154 </div>
155 <br/>
156 <br/>
158 <?php
159 if ($result = getFormByEncounter($pid, $encounter, "id, date, form_id, form_name, formdir, user, deleted")) {
160 echo "<table width='100%' id='partable'>";
161 $divnos=1;
162 foreach ($result as $iter) {
163 $formdir = $iter['formdir'];
165 // skip forms whose 'deleted' flag is set to 1
166 if ($iter['deleted'] == 1) continue;
168 // Skip forms that we are not authorized to see.
169 if (($auth_notes_a) ||
170 ($auth_notes && $iter['user'] == $_SESSION['authUser']) ||
171 ($auth_relaxed && ($formdir == 'sports_fitness' || $formdir == 'podiatry'))) ;
172 else continue;
174 // $form_info = getFormInfoById($iter['id']);
175 if (strtolower(substr($iter['form_name'],0,5)) == 'camos') {
176 //CAMOS generates links from report.php and these links should
177 //be clickable without causing view.php to come up unexpectedly.
178 //I feel that the JQuery code in this file leading to a click
179 //on the report.php content to bring up view.php steps on a
180 //form's autonomy to generate it's own html content in it's report
181 //but until any other form has a problem with this, I will just
182 //make an exception here for CAMOS and allow it to carry out this
183 //functionality for all other forms. --Mark
184 echo '<tr title="' . xl('Edit form') . '" '.
185 'id="'.$formdir.'~'.$iter['form_id'].'">';
186 } else {
187 echo '<tr title="' . xl('Edit form') . '" '.
188 'id="'.$formdir.'~'.$iter['form_id'].'" class="text onerow">';
190 $user = getNameFromUsername($iter['user']);
192 $form_name = ($formdir == 'newpatient') ? xl('Patient Encounter') : xl_form_title($iter['form_name']);
194 echo "<tr>";
195 echo "<td style='border-bottom:1px solid'>";
196 // a link to edit the form
197 echo "<div class='form_header_controls'>";
198 echo "<a target='".
199 ($GLOBALS['concurrent_layout'] ? "_parent" : "Main") .
200 "' href='$rootdir/patient_file/encounter/view_form.php?" .
201 "formname=" . $formdir . "&id=" . $iter['form_id'] .
202 "' onclick='top.restoreSession()' class='css_button_small'><span>" . xl('Edit') . "</span></a>";
204 if (acl_check('admin', 'super') ) {
205 if ( $formdir != 'newpatient') {
206 // a link to delete the form from the encounter
207 echo "<a target='".
208 ($GLOBALS['concurrent_layout'] ? "_parent" : "Main") .
209 "' href='$rootdir/patient_file/encounter/delete_form.php?" .
210 "formname=" . $formdir .
211 "&id=" . $iter['id'] .
212 "&encounter=". $encounter.
213 "&pid=".$pid.
214 "' class='css_button_small' title='" . xl('Delete this form') . "' onclick='top.restoreSession()'><span>" . xl('Delete') . "</span></a>";
215 } else {
216 ?><a href='javascript:;' class='css_button_small' style='color:gray'><span><?php xl('Delete','e'); ?></span></a><?php
220 echo "<div class='form_header'>";
221 echo "<a href='#' onclick='divtoggle(\"spanid_$divnos\",\"divid_$divnos\");' class='small' id='aid_$divnos'><b>$form_name</b> <span class='text'>by " . htmlspecialchars( $user['fname'] . " " . $user['lname'] ) . "</span> (<span id=spanid_$divnos class=\"indicator\">" . xl('Collapse') . "</span>)</a></div>";
222 echo "</td>\n";
223 echo "</tr>";
224 echo "<tr>";
225 echo "<td valign='top' class='formrow'><div class='tab' id='divid_$divnos' style='display:block'>";
227 // Use the form's report.php for display. Forms with names starting with LBF
228 // are list-based forms sharing a single collection of code.
230 if (substr($formdir,0,3) == 'LBF') {
231 include_once($GLOBALS['incdir'] . "/forms/LBF/report.php");
232 call_user_func("lbf_report", $pid, $encounter, 2, $iter['form_id'], $formdir);
234 else {
235 include_once($GLOBALS['incdir'] . "/forms/$formdir/report.php");
236 call_user_func($formdir . "_report", $pid, $encounter, 2, $iter['form_id']);
239 echo "</div></td></tr>";
240 $divnos=$divnos+1;
242 echo "</table>";
246 <?php if ($GLOBALS['athletic_team'] && $GLOBALS['concurrent_layout'] == 2) { ?>
247 <script language='JavaScript'>
248 // If this is the top frame then show the encounters list in the bottom frame.
249 var n = parent.parent.left_nav;
250 var nf = n.document.forms[0];
251 if (parent.window.name == 'RTop' && nf.cb_bot.checked) {
252 var othername = 'RBot';
253 n.setRadio(othername, 'ens');
254 n.loadFrame('ens1', othername, 'patient_file/history/encounters.php');
256 </script>
257 <?php } ?>
259 </div> <!-- end large encounter_forms DIV -->
260 </body>
262 <script language="javascript">
263 // jQuery stuff to make the page a little easier to use
265 $(document).ready(function(){
266 $(".save").click(function() { top.restoreSession(); document.my_form.submit(); });
267 $(".dontsave").click(function() { location.href='<?php echo "$rootdir/patient_file/encounter/$returnurl";?>'; });
269 $(".onerow").mouseover(function() { $(this).toggleClass("highlight"); });
270 $(".onerow").mouseout(function() { $(this).toggleClass("highlight"); });
271 $(".onerow").click(function() { GotoForm(this); });
273 // $(".deleteme").click(function(evt) { deleteme(); evt.stopPropogation(); });
275 var GotoForm = function(obj) {
276 var parts = $(obj).attr("id").split("~");
277 top.restoreSession();
278 <?php if ($GLOBALS['concurrent_layout']): ?>
279 parent.location.href = "<?php echo $rootdir; ?>/patient_file/encounter/view_form.php?formname="+parts[0]+"&id="+parts[1];
280 <?php else: ?>
281 top.Main.location.href = "<?php echo $rootdir; ?>/patient_file/encounter/view_form.php?formname="+parts[0]+"&id="+parts[1];
282 <?php endif; ?>
286 </script>
288 </html>