minor changes to prior commit
[openemr.git] / interface / reports / amc_tracking.php
blob4a4680e9df5a70a20052e984635def1ef1087c32
1 <?php
2 /**
3 * AMC Tracking.
5 * @package OpenEMR
6 * @link http://www.open-emr.org
7 * @author Brady Miller <brady.g.miller@gmail.com>
8 * @copyright Copyright (c) 2011-2017 Brady Miller <brady.g.miller@gmail.com>
9 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
13 require_once("../globals.php");
14 require_once("../../library/patient.inc");
15 require_once "$srcdir/options.inc.php";
16 require_once "$srcdir/amc.php";
18 use OpenEMR\Core\Header;
20 // Collect form parameters (set defaults if empty)
21 $begin_date = (isset($_POST['form_begin_date'])) ? DateTimeToYYYYMMDDHHMMSS(trim($_POST['form_begin_date'])) : "";
22 $end_date = (isset($_POST['form_end_date'])) ? DateTimeToYYYYMMDDHHMMSS(trim($_POST['form_end_date'])) : "";
23 $rule = (isset($_POST['form_rule'])) ? trim($_POST['form_rule']) : "";
24 $provider = trim($_POST['form_provider']);
28 <html>
30 <head>
32 <title><?php echo xlt('Automated Measure Calculations (AMC) Tracking'); ?></title>
34 <?php Header::setupHeader('datetime-picker') ?>
36 <script LANGUAGE="JavaScript">
38 $(document).ready(function() {
39 var win = top.printLogSetup ? top : opener.top;
40 win.printLogSetup(document.getElementById('printbutton'));
42 $('.datepicker').datetimepicker({
43 <?php $datetimepicker_timepicker = true; ?>
44 <?php $datetimepicker_showseconds = true; ?>
45 <?php $datetimepicker_formatInput = true; ?>
46 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
47 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
48 });
49 });
51 function send_sum(patient_id,transaction_id) {
52 if ( $('#send_sum_flag_' + patient_id + '_' + transaction_id).prop('checked') ) {
53 var mode = "add";
55 else {
56 var mode = "remove";
58 top.restoreSession();
59 $.post( "../../library/ajax/amc_misc_data.php",
60 { amc_id: "send_sum_amc",
61 complete: true,
62 mode: mode,
63 patient_id: patient_id,
64 object_category: "transactions",
65 object_id: transaction_id
70 function send_sum_elec(patient_id,transaction_id) {
71 if ( $('#send_sum_elec_flag_' + patient_id + '_' + transaction_id).prop('checked') ) {
72 if ( !$('#send_sum_flag_' + patient_id + '_' + transaction_id).prop('checked') ) {
73 $('#send_sum_elec_flag_' + patient_id + '_' + transaction_id).prop("checked", false);
74 alert("<?php echo xls('Can not set this unless the Summary of Care Sent toggle is set.'); ?>");
75 return false;
77 var mode = "add";
79 else {
80 var mode = "remove";
82 top.restoreSession();
83 $.post( "../../library/ajax/amc_misc_data.php",
84 { amc_id: "send_sum_elec_amc",
85 complete: true,
86 mode: mode,
87 patient_id: patient_id,
88 object_category: "transactions",
89 object_id: transaction_id
94 function provide_rec_pat(patient_id,date_created) {
95 if ( $('#provide_rec_pat_flag_' + patient_id ).prop('checked') ) {
96 var mode = "complete_safe";
98 else {
99 var mode = "uncomplete_safe";
101 top.restoreSession();
102 $.post( "../../library/ajax/amc_misc_data.php",
103 { amc_id: "provide_rec_pat_amc",
104 complete: true,
105 mode: mode,
106 date_created: date_created,
107 patient_id: patient_id
112 function provide_sum_pat(patient_id,encounter_id) {
113 if ( $('#provide_sum_pat_flag_' + patient_id + '_' + encounter_id).prop('checked') ) {
114 var mode = "add";
116 else {
117 var mode = "remove";
119 top.restoreSession();
120 $.post( "../../library/ajax/amc_misc_data.php",
121 { amc_id: "provide_sum_pat_amc",
122 complete: true,
123 mode: mode,
124 patient_id: patient_id,
125 object_category: "form_encounter",
126 object_id: encounter_id
131 </script>
133 <style type="text/css">
135 /* specifically include & exclude from printing */
136 @media print {
137 #report_parameters {
138 visibility: hidden;
139 display: none;
141 #report_parameters_daterange {
142 visibility: visible;
143 display: inline;
145 #report_results table {
146 margin-top: 0px;
150 /* specifically exclude some from the screen */
151 @media screen {
152 #report_parameters_daterange {
153 visibility: hidden;
154 display: none;
158 </style>
159 </head>
161 <body class="body_top">
163 <!-- Required for the popup date selectors -->
164 <div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>
166 <span class='title'><?php echo xlt('Report'); ?> -
168 <?php echo xlt('Automated Measure Calculations (AMC) Tracking'); ?></span>
170 <form method='post' name='theform' id='theform' action='amc_tracking.php' onsubmit='return top.restoreSession()'>
172 <div id="report_parameters">
174 <table>
175 <tr>
176 <td width='470px'>
177 <div style='float:left'>
179 <table class='text'>
181 <tr>
182 <td class='control-label'>
183 <?php echo xlt('Begin Date'); ?>:
184 </td>
185 <td>
186 <input type='text' name='form_begin_date' id="form_begin_date" size='20' value='<?php echo attr(oeFormatDateTime($begin_date, 0, true)); ?>'
187 class='datepicker form-control'>
188 </td>
189 </tr>
191 <tr>
192 <td class='control-label'>
193 <?php echo xlt('End Date'); ?>:
194 </td>
195 <td>
196 <input type='text' name='form_end_date' id="form_end_date" size='20' value='<?php echo attr(oeFormatDateTime($end_date, 0, true)); ?>'
197 class='datepicker form-control'>
198 </td>
199 </tr>
201 <tr>
202 <td class='control-label'>
203 <?php echo xlt('Rule'); ?>:
204 </td>
205 <td>
206 <select name='form_rule' class='form-control'>
207 <option value='send_sum_amc' <?php echo ($rule == "send_sum_amc") ? "selected" : ""; ?>>
208 <?php echo xlt('Send Summaries with Referrals'); ?></option>
209 <option value='provide_rec_pat_amc' <?php echo ($rule == "provide_rec_pat_amc") ? "selected" : ""; ?>>
210 <?php echo xlt('Patient Requested Medical Records'); ?></option>
211 <option value='provide_sum_pat_amc' <?php echo ($rule == "provide_sum_pat_amc") ? "selected" : ""; ?>>
212 <?php echo xlt('Provide Records to Patient for Visit'); ?></option>
213 </select>
214 </td>
215 </tr>
217 <tr>
218 <td class='control-label'>
219 <?php echo xlt('Provider'); ?>:
220 </td>
221 <td>
222 <?php
224 // Build a drop-down list of providers.
227 $query = "SELECT id, lname, fname FROM users WHERE ".
228 "authorized = 1 $provider_facility_filter ORDER BY lname, fname"; //(CHEMED) facility filter
230 $ures = sqlStatement($query);
232 echo " <select name='form_provider' class='form-control'>\n";
233 echo " <option value=''>-- " . xlt('All') . " --\n";
235 while ($urow = sqlFetchArray($ures)) {
236 $provid = $urow['id'];
237 echo " <option value='".attr($provid)."'";
238 if ($provid == $_POST['form_provider']) {
239 echo " selected";
242 echo ">" . text($urow['lname'] . ", " . $urow['fname']) . "\n";
245 echo " </select>\n";
248 </td>
249 </tr>
250 </table>
252 </div>
254 </td>
255 <td align='left' valign='middle' height="100%">
256 <table style='border-left:1px solid; width:100%; height:100%' >
257 <tr>
258 <td>
259 <div class="text-center">
260 <div class="btn-group" role="group">
261 <a href='#' class='btn btn-default btn-save' onclick='$("#form_refresh").attr("value","true"); top.restoreSession(); $("#theform").submit();'>
262 <?php echo xlt('Submit'); ?>
263 </a>
264 <?php if ($_POST['form_refresh']) { ?>
265 <a href='#' class='btn btn-default btn-print' id='printbutton'>
266 <?php echo xlt('Print'); ?>
267 </a>
268 <?php } ?>
269 </div>
270 </div>
271 </td>
272 </tr>
273 </table>
274 </td>
275 </tr>
276 </table>
278 </div> <!-- end of search parameters -->
280 <br>
282 <?php
283 if ($_POST['form_refresh']) {
287 <div id="report_results">
288 <table>
290 <thead>
291 <th>
292 <?php echo xlt('Patient Name'); ?>
293 </th>
295 <th>
296 <?php echo xlt('Patient ID'); ?>
297 </th>
299 <th>
300 <?php
301 if ($rule == "send_sum_amc") {
302 echo xlt('Referral Date');
303 } else if ($rule == "provide_rec_pat_amc") {
304 echo xlt('Record Request Date');
305 } else { // $rule == "provide_sum_pat_amc"
306 echo xlt('Encounter Date');
309 </th>
311 <th>
312 <?php
313 if ($rule == "send_sum_amc") {
314 echo xlt('Referral ID');
315 } else if ($rule == "provide_rec_pat_amc") {
316 echo "&nbsp";
317 } else { // $rule == "provide_sum_pat_amc"
318 echo xlt('Encounter ID');
321 </th>
323 <th>
324 <?php
325 if ($rule == "provide_rec_pat_amc") {
326 echo xlt('Medical Records Sent');
327 } else if ($rule == "send_sum_amc") {
328 echo xlt('Summary of Care Sent');
329 } else { // $rule == "provide_sum_pat_amc"
330 echo xlt('Medical Summary Given');
333 </th>
334 <?php
335 if ($rule == "send_sum_amc") {
336 echo "<th>";
337 echo xlt('Summary of Care Sent Electronically');
338 echo "<th>";
342 </thead>
343 <tbody> <!-- added for better print-ability -->
344 <?php
346 // Send the request for information
347 $resultsArray = amcTrackingRequest($rule, $begin_date, $end_date, $provider);
351 <?php
352 foreach ($resultsArray as $result) {
353 echo "<tr bgcolor='" . $bgcolor ."'>";
354 echo "<td>" . text($result['lname'].",".$result['fname']) . "</td>";
355 echo "<td>" . text($result['pid']) . "</td>";
356 echo "<td>" . text(oeFormatDateTime($result['date'], "global", true)) . "</td>";
357 if ($rule == "send_sum_amc" || $rule == "provide_sum_pat_amc") {
358 echo "<td>" . text($result['id']) . "</td>";
359 } else { //$rule == "provide_rec_pat_amc"
360 echo "<td>&nbsp</td>";
363 if ($rule == "send_sum_amc") {
364 echo "<td><input type='checkbox' id='send_sum_flag_".attr($result['pid'])."_".attr($result['id'])."' onclick='send_sum(\"".attr($result['pid'])."\",\"".attr($result['id'])."\")'>" . xlt('Yes') . "</td>";
365 echo "<td><input type='checkbox' id='send_sum_elec_flag_".attr($result['pid'])."_".attr($result['id'])."' onclick='send_sum_elec(\"".attr($result['pid'])."\",\"".attr($result['id'])."\")'>" . xlt('Yes') . "</td>";
366 } else if ($rule == "provide_rec_pat_amc") {
367 echo "<td><input type='checkbox' id='provide_rec_pat_flag_".attr($result['pid'])."' onclick='provide_rec_pat(\"".attr($result['pid'])."\",\"".attr($result['date'])."\")'>" . xlt('Yes') . "</td>";
368 } else { //$rule == "provide_sum_pat_amc"
369 echo "<td><input type='checkbox' id='provide_sum_pat_flag_".attr($result['pid'])."_".attr($result['id'])."' onclick='provide_sum_pat(\"".attr($result['pid'])."\",\"".attr($result['id'])."\")'>" . xlt('Yes') . "</td>";
372 echo "</tr>";
376 </tbody>
377 </table>
378 </div> <!-- end of search results -->
379 <?php } else { ?>
380 <div class='text'>
381 <?php echo xlt('Please input search criteria above, and click Submit to view results.'); ?>
382 </div>
383 <?php } ?>
385 <input type='hidden' name='form_refresh' id='form_refresh' value=''/>
387 </form>
389 </body>
391 </html>