Support for optional logging of print actions.
[openemr.git] / interface / reports / amc_tracking.php
blob79f5697ebe0d293ce88c666601338d0cfe411468
1 <?php
2 // Copyright (C) 2011 Brady Miller <brady@sparmy.com>
3 //
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
9 //SANITIZE ALL ESCAPES
10 $sanitize_all_escapes=true;
13 //STOP FAKE REGISTER GLOBALS
14 $fake_register_globals=false;
17 require_once("../globals.php");
18 require_once("../../library/patient.inc");
19 require_once("$srcdir/formatting.inc.php");
20 require_once "$srcdir/options.inc.php";
21 require_once "$srcdir/formdata.inc.php";
22 require_once "$srcdir/amc.php";
24 // Collect form parameters (set defaults if empty)
25 $begin_date = (isset($_POST['form_begin_date'])) ? trim($_POST['form_begin_date']) : "";
26 $begin_date = (isset($_POST['form_end_date'])) ? trim($_POST['form_end_date']) : "";
27 $rule = (isset($_POST['form_rule'])) ? trim($_POST['form_rule']) : "";
28 $provider = trim($_POST['form_provider']);
32 <html>
34 <head>
35 <?php html_header_show();?>
37 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
39 <title><?php echo htmlspecialchars( xl('Automated Measure Calculations (AMC) Tracking'), ENT_NOQUOTES); ?></title>
41 <script type="text/javascript" src="../../library/overlib_mini.js"></script>
42 <script type="text/javascript" src="../../library/textformat.js"></script>
43 <script type="text/javascript" src="../../library/dialog.js"></script>
44 <script type="text/javascript" src="../../library/js/jquery.1.3.2.js"></script>
46 <script LANGUAGE="JavaScript">
48 var mypcc = '<?php echo $GLOBALS['phone_country_code'] ?>';
50 $(document).ready(function() {
51 var win = top.printLogSetup ? top : opener.top;
52 win.printLogSetup(document.getElementById('printbutton'));
53 });
55 function send_sum(patient_id,transaction_id) {
56 if ( $('#send_sum_flag').attr('checked') ) {
57 var mode = "add";
59 else {
60 var mode = "remove";
62 top.restoreSession();
63 $.post( "../../library/ajax/amc_misc_data.php",
64 { amc_id: "send_sum_amc",
65 complete: true,
66 mode: mode,
67 patient_id: patient_id,
68 object_category: "transactions",
69 object_id: transaction_id
74 function provide_rec_pat(patient_id,date_created) {
75 if ( $('#provide_rec_pat_flag').attr('checked') ) {
76 var mode = "complete_safe";
78 else {
79 var mode = "uncomplete_safe";
81 top.restoreSession();
82 $.post( "../../library/ajax/amc_misc_data.php",
83 { amc_id: "provide_rec_pat_amc",
84 complete: true,
85 mode: mode,
86 date_created: date_created,
87 patient_id: patient_id
92 function provide_sum_pat(patient_id,encounter_id) {
93 if ( $('#provide_sum_pat_flag').attr('checked') ) {
94 var mode = "add";
96 else {
97 var mode = "remove";
99 top.restoreSession();
100 $.post( "../../library/ajax/amc_misc_data.php",
101 { amc_id: "provide_sum_pat_amc",
102 complete: true,
103 mode: mode,
104 patient_id: patient_id,
105 object_category: "form_encounter",
106 object_id: encounter_id
111 </script>
113 <style type="text/css">
115 /* specifically include & exclude from printing */
116 @media print {
117 #report_parameters {
118 visibility: hidden;
119 display: none;
121 #report_parameters_daterange {
122 visibility: visible;
123 display: inline;
125 #report_results table {
126 margin-top: 0px;
130 /* specifically exclude some from the screen */
131 @media screen {
132 #report_parameters_daterange {
133 visibility: hidden;
134 display: none;
138 </style>
139 </head>
141 <body class="body_top">
143 <!-- Required for the popup date selectors -->
144 <div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>
146 <span class='title'><?php echo htmlspecialchars( xl('Report'), ENT_NOQUOTES); ?> -
148 <?php echo htmlspecialchars( xl('Automated Measure Calculations (AMC) Tracking'), ENT_NOQUOTES); ?></span>
150 <form method='post' name='theform' id='theform' action='amc_tracking.php' onsubmit='return top.restoreSession()'>
152 <div id="report_parameters">
154 <table>
155 <tr>
156 <td width='470px'>
157 <div style='float:left'>
159 <table class='text'>
161 <tr>
162 <td class='label'>
163 <?php echo htmlspecialchars( xl('Begin Date'), ENT_NOQUOTES); ?>:
164 </td>
165 <td>
166 <input type='text' name='form_begin_date' id="form_begin_date" size='20' value='<?php echo htmlspecialchars( $begin_date, ENT_QUOTES); ?>'
167 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)' title='<?php echo htmlspecialchars( xl('yyyy-mm-dd hh:mm:ss'), ENT_QUOTES); ?>'>
168 <img src='../pic/show_calendar.gif' align='absbottom' width='24' height='22'
169 id='img_begin_date' border='0' alt='[?]' style='cursor:pointer'
170 title='<?php echo htmlspecialchars( xl('Click here to choose a date'), ENT_QUOTES); ?>'>
171 </td>
172 </tr>
174 <tr>
175 <td class='label'>
176 <?php echo htmlspecialchars( xl('End Date'), ENT_NOQUOTES); ?>:
177 </td>
178 <td>
179 <input type='text' name='form_end_date' id="form_end_date" size='20' value='<?php echo htmlspecialchars( $end_date, ENT_QUOTES); ?>'
180 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)' title='<?php echo htmlspecialchars( xl('yyyy-mm-dd hh:mm:ss'), ENT_QUOTES); ?>'>
181 <img src='../pic/show_calendar.gif' align='absbottom' width='24' height='22'
182 id='img_end_date' border='0' alt='[?]' style='cursor:pointer'
183 title='<?php echo htmlspecialchars( xl('Click here to choose a date'), ENT_QUOTES); ?>'>
184 </td>
185 </tr>
187 <tr>
188 <td class='label'>
189 <?php echo htmlspecialchars( xl('Rule'), ENT_NOQUOTES); ?>:
190 </td>
191 <td>
192 <select name='form_rule'>
193 <option value='send_sum_amc' <?php if ($rule == "send_sum_amc") echo "selected"; ?>>
194 <?php echo htmlspecialchars( xl('Send Summaries with Referrals'), ENT_NOQUOTES); ?></option>
195 <option value='provide_rec_pat_amc' <?php if ($rule == "provide_rec_pat_amc") echo "selected"; ?>>
196 <?php echo htmlspecialchars( xl('Patient Requested Medical Records'), ENT_NOQUOTES); ?></option>
197 <option value='provide_sum_pat_amc' <?php if ($rule == "provide_sum_pat_amc") echo "selected"; ?>>
198 <?php echo htmlspecialchars( xl('Provide Records to Patient for Visit'), ENT_NOQUOTES); ?></option>
199 </select>
200 </td>
201 </tr>
203 <tr>
204 <td class='label'>
205 <?php echo htmlspecialchars( xl('Provider'), ENT_NOQUOTES); ?>:
206 </td>
207 <td>
208 <?php
210 // Build a drop-down list of providers.
213 $query = "SELECT id, lname, fname FROM users WHERE ".
214 "authorized = 1 $provider_facility_filter ORDER BY lname, fname"; //(CHEMED) facility filter
216 $ures = sqlStatement($query);
218 echo " <select name='form_provider'>\n";
219 echo " <option value=''>-- " . htmlspecialchars( xl('All'), ENT_NOQUOTES) . " --\n";
221 while ($urow = sqlFetchArray($ures)) {
222 $provid = $urow['id'];
223 echo " <option value='".htmlspecialchars( $provid, ENT_QUOTES)."'";
224 if ($provid == $_POST['form_provider']) echo " selected";
225 echo ">" . htmlspecialchars( $urow['lname'] . ", " . $urow['fname'], ENT_NOQUOTES) . "\n";
228 echo " </select>\n";
231 </td>
232 </tr>
233 </table>
235 </div>
237 </td>
238 <td align='left' valign='middle' height="100%">
239 <table style='border-left:1px solid; width:100%; height:100%' >
240 <tr>
241 <td>
242 <div style='margin-left:15px'>
243 <a href='#' class='css_button' onclick='$("#form_refresh").attr("value","true"); top.restoreSession(); $("#theform").submit();'>
244 <span>
245 <?php echo htmlspecialchars( xl('Submit'), ENT_NOQUOTES); ?>
246 </span>
247 </a>
248 <?php if ($_POST['form_refresh']) { ?>
249 <a href='#' class='css_button' id='printbutton'>
250 <span>
251 <?php echo htmlspecialchars( xl('Print'), ENT_NOQUOTES); ?>
252 </span>
253 </a>
254 <?php } ?>
255 </div>
256 </td>
257 </tr>
258 </table>
259 </td>
260 </tr>
261 </table>
263 </div> <!-- end of search parameters -->
265 <br>
267 <?php
268 if ($_POST['form_refresh']) {
272 <div id="report_results">
273 <table>
275 <thead>
276 <th>
277 <?php echo htmlspecialchars( xl('Patient Name'), ENT_NOQUOTES); ?>
278 </th>
280 <th>
281 <?php echo htmlspecialchars( xl('Patient ID'), ENT_NOQUOTES); ?>
282 </th>
284 <th>
285 <?php
286 if ($rule == "send_sum_amc") {
287 echo htmlspecialchars( xl('Referral Date'), ENT_NOQUOTES);
289 else if ($rule == "provide_rec_pat_amc") {
290 echo htmlspecialchars( xl('Record Request Date'), ENT_NOQUOTES);
292 else { // $rule == "provide_sum_pat_amc"
293 echo htmlspecialchars( xl('Encounter Date'), ENT_NOQUOTES);
296 </th>
298 <th>
299 <?php
300 if ($rule == "send_sum_amc") {
301 echo htmlspecialchars( xl('Referral ID'), ENT_NOQUOTES);
303 else if ($rule == "provide_rec_pat_amc") {
304 echo "&nbsp";
306 else { // $rule == "provide_sum_pat_amc"
307 echo htmlspecialchars( xl('Encounter ID'), ENT_NOQUOTES);
310 </th>
312 <th>
313 <?php
314 if ($rule == "send_sum_amc" || $rule == "provide_rec_pat_amc") {
315 echo htmlspecialchars( xl('Medical Records Sent'), ENT_NOQUOTES);
317 else { // $rule == "provide_sum_pat_amc"
318 echo htmlspecialchars( xl('Medical Summary Given'), ENT_NOQUOTES);
321 </th>
323 </thead>
324 <tbody> <!-- added for better print-ability -->
325 <?php
327 // Send the request for information
328 $resultsArray = amcTrackingRequest($rule,$begin_date,$end_date,$provider);
332 <?php
333 foreach ($resultsArray as $result) {
334 echo "<tr bgcolor='" . $bgcolor ."'>";
335 echo "<td>" . htmlspecialchars($result['lname'].",".$result['fname'], ENT_NOQUOTES) . "</td>";
336 echo "<td>" . htmlspecialchars($result['pid'],ENT_NOQUOTES) . "</td>";
337 echo "<td>" . htmlspecialchars($result['date'],ENT_NOQUOTES) . "</td>";
338 if ($rule == "send_sum_amc" || $rule == "provide_sum_pat_amc") {
339 echo "<td>" . htmlspecialchars($result['id'],ENT_NOQUOTES) . "</td>";
341 else { //$rule == "provide_rec_pat_amc"
342 echo "&nbsp";
345 if ($rule == "send_sum_amc") {
346 echo "<td><input type='checkbox' id='send_sum_flag' onclick='send_sum(\"".htmlspecialchars($result['pid'],ENT_QUOTES)."\",\"".htmlspecialchars($result['id'],ENT_QUOTES)."\")'>" . htmlspecialchars( xl('Yes'), ENT_NOQUOTES) . "</td>";
348 else if ($rule == "provide_rec_pat_amc") {
349 echo "<td><input type='checkbox' id='provide_rec_pat_flag' onclick='provide_rec_pat(\"".htmlspecialchars($result['pid'],ENT_QUOTES)."\",\"".htmlspecialchars($result['date'],ENT_QUOTES)."\")'>" . htmlspecialchars( xl('Yes'), ENT_NOQUOTES) . "</td>";
351 else { //$rule == "provide_sum_pat_amc"
352 echo "<td><input type='checkbox' id='provide_sum_pat_flag' onclick='provide_sum_pat(\"".htmlspecialchars($result['pid'],ENT_QUOTES)."\",\"".htmlspecialchars($result['id'],ENT_QUOTES)."\")'>" . htmlspecialchars( xl('Yes'), ENT_NOQUOTES) . "</td>";
354 echo "</tr>";
358 </tbody>
359 </table>
360 </div> <!-- end of search results -->
361 <?php } else { ?>
362 <div class='text'>
363 <?php echo htmlspecialchars( xl('Please input search criteria above, and click Submit to view results.'), ENT_NOQUOTES); ?>
364 </div>
365 <?php } ?>
367 <input type='hidden' name='form_refresh' id='form_refresh' value=''/>
369 </form>
371 </body>
373 <!-- stuff for the popup calendar -->
374 <style type="text/css">@import url(../../library/dynarch_calendar.css);</style>
375 <script type="text/javascript" src="../../library/dynarch_calendar.js"></script>
376 <?php include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?>
377 <script type="text/javascript" src="../../library/dynarch_calendar_setup.js"></script>
378 <script language="Javascript">
379 Calendar.setup({inputField:"form_begin_date", ifFormat:"%Y-%m-%d %H:%M:%S", button:"img_begin_date", showsTime:'true'});
380 Calendar.setup({inputField:"form_end_date", ifFormat:"%Y-%m-%d %H:%M:%S", button:"img_end_date", showsTime:'true'});
382 </script>
384 </html>