migrated ubiquitous libraries to composer autoloader (#421)
[openemr.git] / interface / reports / amc_tracking.php
blobee99fb89032425f31776570d247261363f446d25
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/amc.php";
23 // Collect form parameters (set defaults if empty)
24 $begin_date = (isset($_POST['form_begin_date'])) ? trim($_POST['form_begin_date']) : "";
25 $end_date = (isset($_POST['form_end_date'])) ? trim($_POST['form_end_date']) : "";
26 $rule = (isset($_POST['form_rule'])) ? trim($_POST['form_rule']) : "";
27 $provider = trim($_POST['form_provider']);
31 <html>
33 <head>
34 <?php html_header_show();?>
36 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
38 <title><?php echo htmlspecialchars( xl('Automated Measure Calculations (AMC) Tracking'), ENT_NOQUOTES); ?></title>
40 <script type="text/javascript" src="../../library/overlib_mini.js"></script>
41 <script type="text/javascript" src="../../library/textformat.js"></script>
42 <script type="text/javascript" src="../../library/dialog.js?v=<?php echo $v_js_includes; ?>"></script>
43 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-3-2/index.js"></script>
45 <script LANGUAGE="JavaScript">
47 var mypcc = '<?php echo $GLOBALS['phone_country_code'] ?>';
49 $(document).ready(function() {
50 var win = top.printLogSetup ? top : opener.top;
51 win.printLogSetup(document.getElementById('printbutton'));
52 });
54 function send_sum(patient_id,transaction_id) {
55 if ( $('#send_sum_flag_' + patient_id + '_' + transaction_id).attr('checked') ) {
56 var mode = "add";
58 else {
59 var mode = "remove";
61 top.restoreSession();
62 $.post( "../../library/ajax/amc_misc_data.php",
63 { amc_id: "send_sum_amc",
64 complete: true,
65 mode: mode,
66 patient_id: patient_id,
67 object_category: "transactions",
68 object_id: transaction_id
73 function send_sum_elec(patient_id,transaction_id) {
74 if ( $('#send_sum_elec_flag_' + patient_id + '_' + transaction_id).attr('checked') ) {
75 if ( !$('#send_sum_flag_' + patient_id + '_' + transaction_id).attr('checked') ) {
76 $('#send_sum_elec_flag_' + patient_id + '_' + transaction_id).removeAttr("checked");
77 alert("<?php echo xls('Can not set this unless the Summary of Care Sent toggle is set.'); ?>");
78 return false;
80 var mode = "add";
82 else {
83 var mode = "remove";
85 top.restoreSession();
86 $.post( "../../library/ajax/amc_misc_data.php",
87 { amc_id: "send_sum_elec_amc",
88 complete: true,
89 mode: mode,
90 patient_id: patient_id,
91 object_category: "transactions",
92 object_id: transaction_id
97 function provide_rec_pat(patient_id,date_created) {
98 if ( $('#provide_rec_pat_flag_' + patient_id ).attr('checked') ) {
99 var mode = "complete_safe";
101 else {
102 var mode = "uncomplete_safe";
104 top.restoreSession();
105 $.post( "../../library/ajax/amc_misc_data.php",
106 { amc_id: "provide_rec_pat_amc",
107 complete: true,
108 mode: mode,
109 date_created: date_created,
110 patient_id: patient_id
115 function provide_sum_pat(patient_id,encounter_id) {
116 if ( $('#provide_sum_pat_flag_' + patient_id + '_' + encounter_id).attr('checked') ) {
117 var mode = "add";
119 else {
120 var mode = "remove";
122 top.restoreSession();
123 $.post( "../../library/ajax/amc_misc_data.php",
124 { amc_id: "provide_sum_pat_amc",
125 complete: true,
126 mode: mode,
127 patient_id: patient_id,
128 object_category: "form_encounter",
129 object_id: encounter_id
134 </script>
136 <style type="text/css">
138 /* specifically include & exclude from printing */
139 @media print {
140 #report_parameters {
141 visibility: hidden;
142 display: none;
144 #report_parameters_daterange {
145 visibility: visible;
146 display: inline;
148 #report_results table {
149 margin-top: 0px;
153 /* specifically exclude some from the screen */
154 @media screen {
155 #report_parameters_daterange {
156 visibility: hidden;
157 display: none;
161 </style>
162 </head>
164 <body class="body_top">
166 <!-- Required for the popup date selectors -->
167 <div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>
169 <span class='title'><?php echo htmlspecialchars( xl('Report'), ENT_NOQUOTES); ?> -
171 <?php echo htmlspecialchars( xl('Automated Measure Calculations (AMC) Tracking'), ENT_NOQUOTES); ?></span>
173 <form method='post' name='theform' id='theform' action='amc_tracking.php' onsubmit='return top.restoreSession()'>
175 <div id="report_parameters">
177 <table>
178 <tr>
179 <td width='470px'>
180 <div style='float:left'>
182 <table class='text'>
184 <tr>
185 <td class='label'>
186 <?php echo htmlspecialchars( xl('Begin Date'), ENT_NOQUOTES); ?>:
187 </td>
188 <td>
189 <input type='text' name='form_begin_date' id="form_begin_date" size='20' value='<?php echo htmlspecialchars( $begin_date, ENT_QUOTES); ?>'
190 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)' title='<?php echo htmlspecialchars( xl('yyyy-mm-dd hh:mm:ss'), ENT_QUOTES); ?>'>
191 <img src='../pic/show_calendar.gif' align='absbottom' width='24' height='22'
192 id='img_begin_date' border='0' alt='[?]' style='cursor:pointer'
193 title='<?php echo htmlspecialchars( xl('Click here to choose a date'), ENT_QUOTES); ?>'>
194 </td>
195 </tr>
197 <tr>
198 <td class='label'>
199 <?php echo htmlspecialchars( xl('End Date'), ENT_NOQUOTES); ?>:
200 </td>
201 <td>
202 <input type='text' name='form_end_date' id="form_end_date" size='20' value='<?php echo htmlspecialchars( $end_date, ENT_QUOTES); ?>'
203 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)' title='<?php echo htmlspecialchars( xl('yyyy-mm-dd hh:mm:ss'), ENT_QUOTES); ?>'>
204 <img src='../pic/show_calendar.gif' align='absbottom' width='24' height='22'
205 id='img_end_date' border='0' alt='[?]' style='cursor:pointer'
206 title='<?php echo htmlspecialchars( xl('Click here to choose a date'), ENT_QUOTES); ?>'>
207 </td>
208 </tr>
210 <tr>
211 <td class='label'>
212 <?php echo htmlspecialchars( xl('Rule'), ENT_NOQUOTES); ?>:
213 </td>
214 <td>
215 <select name='form_rule'>
216 <option value='send_sum_amc' <?php if ($rule == "send_sum_amc") echo "selected"; ?>>
217 <?php echo htmlspecialchars( xl('Send Summaries with Referrals'), ENT_NOQUOTES); ?></option>
218 <option value='provide_rec_pat_amc' <?php if ($rule == "provide_rec_pat_amc") echo "selected"; ?>>
219 <?php echo htmlspecialchars( xl('Patient Requested Medical Records'), ENT_NOQUOTES); ?></option>
220 <option value='provide_sum_pat_amc' <?php if ($rule == "provide_sum_pat_amc") echo "selected"; ?>>
221 <?php echo htmlspecialchars( xl('Provide Records to Patient for Visit'), ENT_NOQUOTES); ?></option>
222 </select>
223 </td>
224 </tr>
226 <tr>
227 <td class='label'>
228 <?php echo htmlspecialchars( xl('Provider'), ENT_NOQUOTES); ?>:
229 </td>
230 <td>
231 <?php
233 // Build a drop-down list of providers.
236 $query = "SELECT id, lname, fname FROM users WHERE ".
237 "authorized = 1 $provider_facility_filter ORDER BY lname, fname"; //(CHEMED) facility filter
239 $ures = sqlStatement($query);
241 echo " <select name='form_provider'>\n";
242 echo " <option value=''>-- " . htmlspecialchars( xl('All'), ENT_NOQUOTES) . " --\n";
244 while ($urow = sqlFetchArray($ures)) {
245 $provid = $urow['id'];
246 echo " <option value='".htmlspecialchars( $provid, ENT_QUOTES)."'";
247 if ($provid == $_POST['form_provider']) echo " selected";
248 echo ">" . htmlspecialchars( $urow['lname'] . ", " . $urow['fname'], ENT_NOQUOTES) . "\n";
251 echo " </select>\n";
254 </td>
255 </tr>
256 </table>
258 </div>
260 </td>
261 <td align='left' valign='middle' height="100%">
262 <table style='border-left:1px solid; width:100%; height:100%' >
263 <tr>
264 <td>
265 <div style='margin-left:15px'>
266 <a href='#' class='css_button' onclick='$("#form_refresh").attr("value","true"); top.restoreSession(); $("#theform").submit();'>
267 <span>
268 <?php echo htmlspecialchars( xl('Submit'), ENT_NOQUOTES); ?>
269 </span>
270 </a>
271 <?php if ($_POST['form_refresh']) { ?>
272 <a href='#' class='css_button' id='printbutton'>
273 <span>
274 <?php echo htmlspecialchars( xl('Print'), ENT_NOQUOTES); ?>
275 </span>
276 </a>
277 <?php } ?>
278 </div>
279 </td>
280 </tr>
281 </table>
282 </td>
283 </tr>
284 </table>
286 </div> <!-- end of search parameters -->
288 <br>
290 <?php
291 if ($_POST['form_refresh']) {
295 <div id="report_results">
296 <table>
298 <thead>
299 <th>
300 <?php echo htmlspecialchars( xl('Patient Name'), ENT_NOQUOTES); ?>
301 </th>
303 <th>
304 <?php echo htmlspecialchars( xl('Patient ID'), ENT_NOQUOTES); ?>
305 </th>
307 <th>
308 <?php
309 if ($rule == "send_sum_amc") {
310 echo htmlspecialchars( xl('Referral Date'), ENT_NOQUOTES);
312 else if ($rule == "provide_rec_pat_amc") {
313 echo htmlspecialchars( xl('Record Request Date'), ENT_NOQUOTES);
315 else { // $rule == "provide_sum_pat_amc"
316 echo htmlspecialchars( xl('Encounter Date'), ENT_NOQUOTES);
319 </th>
321 <th>
322 <?php
323 if ($rule == "send_sum_amc") {
324 echo htmlspecialchars( xl('Referral ID'), ENT_NOQUOTES);
326 else if ($rule == "provide_rec_pat_amc") {
327 echo "&nbsp";
329 else { // $rule == "provide_sum_pat_amc"
330 echo htmlspecialchars( xl('Encounter ID'), ENT_NOQUOTES);
333 </th>
335 <th>
336 <?php
337 if ($rule == "provide_rec_pat_amc") {
338 echo htmlspecialchars( xl('Medical Records Sent'), ENT_NOQUOTES);
340 else if ($rule == "send_sum_amc") {
341 echo htmlspecialchars( xl('Summary of Care Sent'), ENT_NOQUOTES);
343 else { // $rule == "provide_sum_pat_amc"
344 echo htmlspecialchars( xl('Medical Summary Given'), ENT_NOQUOTES);
347 </th>
348 <?php
349 if ($rule == "send_sum_amc") {
350 echo "<th>";
351 echo htmlspecialchars( xl('Summary of Care Sent Electronically'), ENT_NOQUOTES);
352 echo "<th>";
356 </thead>
357 <tbody> <!-- added for better print-ability -->
358 <?php
360 // Send the request for information
361 $resultsArray = amcTrackingRequest($rule,$begin_date,$end_date,$provider);
365 <?php
366 foreach ($resultsArray as $result) {
367 echo "<tr bgcolor='" . $bgcolor ."'>";
368 echo "<td>" . htmlspecialchars($result['lname'].",".$result['fname'], ENT_NOQUOTES) . "</td>";
369 echo "<td>" . htmlspecialchars($result['pid'],ENT_NOQUOTES) . "</td>";
370 echo "<td>" . htmlspecialchars($result['date'],ENT_NOQUOTES) . "</td>";
371 if ($rule == "send_sum_amc" || $rule == "provide_sum_pat_amc") {
372 echo "<td>" . htmlspecialchars($result['id'],ENT_NOQUOTES) . "</td>";
374 else { //$rule == "provide_rec_pat_amc"
375 echo "&nbsp";
378 if ($rule == "send_sum_amc") {
379 echo "<td><input type='checkbox' id='send_sum_flag_".attr($result['pid'])."_".attr($result['id'])."' onclick='send_sum(\"".htmlspecialchars($result['pid'],ENT_QUOTES)."\",\"".htmlspecialchars($result['id'],ENT_QUOTES)."\")'>" . htmlspecialchars( xl('Yes'), ENT_NOQUOTES) . "</td>";
380 echo "<td><input type='checkbox' id='send_sum_elec_flag_".attr($result['pid'])."_".attr($result['id'])."' onclick='send_sum_elec(\"".htmlspecialchars($result['pid'],ENT_QUOTES)."\",\"".htmlspecialchars($result['id'],ENT_QUOTES)."\")'>" . htmlspecialchars( xl('Yes'), ENT_NOQUOTES) . "</td>";
382 else if ($rule == "provide_rec_pat_amc") {
383 echo "<td><input type='checkbox' id='provide_rec_pat_flag_".attr($result['pid'])."' onclick='provide_rec_pat(\"".htmlspecialchars($result['pid'],ENT_QUOTES)."\",\"".htmlspecialchars($result['date'],ENT_QUOTES)."\")'>" . htmlspecialchars( xl('Yes'), ENT_NOQUOTES) . "</td>";
385 else { //$rule == "provide_sum_pat_amc"
386 echo "<td><input type='checkbox' id='provide_sum_pat_flag_".attr($result['pid'])."_".attr($result['id'])."' onclick='provide_sum_pat(\"".htmlspecialchars($result['pid'],ENT_QUOTES)."\",\"".htmlspecialchars($result['id'],ENT_QUOTES)."\")'>" . htmlspecialchars( xl('Yes'), ENT_NOQUOTES) . "</td>";
388 echo "</tr>";
392 </tbody>
393 </table>
394 </div> <!-- end of search results -->
395 <?php } else { ?>
396 <div class='text'>
397 <?php echo htmlspecialchars( xl('Please input search criteria above, and click Submit to view results.'), ENT_NOQUOTES); ?>
398 </div>
399 <?php } ?>
401 <input type='hidden' name='form_refresh' id='form_refresh' value=''/>
403 </form>
405 </body>
407 <!-- stuff for the popup calendar -->
408 <style type="text/css">@import url(../../library/dynarch_calendar.css);</style>
409 <script type="text/javascript" src="../../library/dynarch_calendar.js"></script>
410 <?php include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?>
411 <script type="text/javascript" src="../../library/dynarch_calendar_setup.js"></script>
412 <script language="Javascript">
413 Calendar.setup({inputField:"form_begin_date", ifFormat:"%Y-%m-%d %H:%M:%S", button:"img_begin_date", showsTime:'true'});
414 Calendar.setup({inputField:"form_end_date", ifFormat:"%Y-%m-%d %H:%M:%S", button:"img_end_date", showsTime:'true'});
416 </script>
418 </html>