Improved/optimized CDR engine reports (and patient reminders) and added a
[openemr.git] / interface / batchcom / batch_reminders.php
blob3ac94a135549ee575b2a4539f934ab2e4a3f3b6d
1 <?php
2 // Copyright (C) 2010 OpenEMR Support LLC
3 // This program is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU General Public License
5 // as published by the Free Software Foundation; either version 2
6 // of the License, or (at your option) any later version.
8 //SANITIZE ALL ESCAPES
9 $sanitize_all_escapes=true;
11 //STOP FAKE REGISTER GLOBALS
12 $fake_register_globals=false;
14 require_once(dirname(__FILE__)."/../../interface/globals.php");
15 require_once ($GLOBALS['srcdir'] . "/classes/postmaster.php");
16 require_once ($GLOBALS['srcdir'] . "/maviq_phone_api.php");
17 require_once($GLOBALS['srcdir'] . "/reminders.php");
18 require_once($GLOBALS['srcdir'] . "/report_database.inc");
20 // This is only pertinent for users of php versions less than 5.2
21 // (ie. this wrapper is only loaded when php version is less than
22 // 5.2; otherwise the native php json functions are used)
23 require_once "$srcdir/jsonwrapper/jsonwrapper.php";
25 //To improve performance and not freeze the session when running this
26 // report, turn off session writing. Note that php session variables
27 // can not be modified after the line below. So, if need to do any php
28 // session work in the future, then will need to remove this line.
29 session_write_close();
31 //Remove time limit, since script can take many minutes
32 set_time_limit(0);
34 // If report_id, then just going to show the report log
35 $report_id = ($_GET['report_id']) ? $_GET['report_id'] : "";
37 // Set the "nice" level of the process for this script when. When the "nice" level
38 // is increased, this cpu intensive script will have less affect on the performance
39 // of other server activities, albeit it may negatively impact the performance
40 // of this script (note this is only applicable for linux).
41 if (empty($report_id) && !empty($GLOBALS['pat_rem_clin_nice'])) {
42 proc_nice($GLOBALS['pat_rem_clin_nice']);
46 <html>
47 <head>
48 <?php html_header_show();?>
49 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
50 <link rel="stylesheet" href="batchcom.css" type="text/css">
51 </head>
52 <body class="body_top">
53 <span class="title"><?php echo htmlspecialchars(xl('Patient Reminder Batch Job'), ENT_NOQUOTES)?></span>
55 <?php
56 // Collect the sender information
57 // TODO
58 // $sender_name
59 // $email_address
63 <table>
64 <tr>
65 <td class='text' align='left' colspan="3"><br>
67 <?php if ($report_id) {
68 // collect log from a previous run to show
69 $results_log = collectReportDatabase($report_id);
70 $data_log = json_decode($results_log['data'],TRUE);
71 $update_rem_log = $data_log[0];
72 if ($results_log['type'] == "process_send_reminders") {
73 $send_rem_log = $data_log[1];
75 echo "<span class='text'>" . xlt("Date of Report") . ": " . text($results_log['date_report']) . "</span><br><br>";
77 else {
78 $update_rem_log = update_reminders_batch_method();
79 $send_rem_log = send_reminders();
83 <span class="text"><?php echo htmlspecialchars(xl('The patient reminders have been updated'), ENT_NOQUOTES) . ":"?></span><br>
84 <span class="text"><?php echo htmlspecialchars(xl('Total active actions'), ENT_NOQUOTES) . ": " . $update_rem_log['total_active_actions'];?></span><br>
85 <span class="text"><?php echo htmlspecialchars(xl('Total active reminders before update'), ENT_NOQUOTES) . ": " . $update_rem_log['total_pre_active_reminders'];?></span><br>
86 <span class="text"><?php echo htmlspecialchars(xl('Total unsent reminders before update'), ENT_NOQUOTES) . ": " . $update_rem_log['total_pre_unsent_reminders'];?></span><br>
87 <span class="text"><?php echo htmlspecialchars(xl('Total active reminders after update'), ENT_NOQUOTES) . ": " . $update_rem_log['total_post_active_reminders'];?></span><br>
88 <span class="text"><?php echo htmlspecialchars(xl('Total unsent reminders after update'), ENT_NOQUOTES) . ": " . $update_rem_log['total_post_unsent_reminders'];?></span><br>
89 <span class="text"><?php echo htmlspecialchars(xl('Total new reminders'), ENT_NOQUOTES) . ": " . $update_rem_log['number_new_reminders'];?></span><br>
90 <span class="text"><?php echo htmlspecialchars(xl('Total updated reminders'), ENT_NOQUOTES) . ": " . $update_rem_log['number_updated_reminders'];?></span><br>
91 <span class="text"><?php echo htmlspecialchars(xl('Total inactivated reminders'), ENT_NOQUOTES) . ": " . $update_rem_log['number_inactivated_reminders'];?></span><br>
92 <span class="text"><?php echo htmlspecialchars(xl('Total unchanged reminders'), ENT_NOQUOTES) . ": " . $update_rem_log['number_unchanged_reminders'];?></span><br>
94 <?php if ($results_log['type'] != "process_reminders") { ?>
95 <br><span class="text"><?php echo htmlspecialchars(xl('The patient reminders have been sent'), ENT_NOQUOTES) . ":"?></span><br>
96 <span class="text"><?php echo htmlspecialchars(xl('Total unsent reminders before sending process'), ENT_NOQUOTES) . ": " . $send_rem_log['total_pre_unsent_reminders'];?></span><br>
97 <span class="text"><?php echo htmlspecialchars(xl('Total unsent reminders after sending process'), ENT_NOQUOTES) . ": " . $send_rem_log['total_post_unsent_reminders'];?></span><br>
98 <span class="text"><?php echo htmlspecialchars(xl('Total successful reminders sent via email'), ENT_NOQUOTES) . ": " . $send_rem_log['number_success_emails'];?></span><br>
99 <span class="text"><?php echo htmlspecialchars(xl('Total failed reminders sent via email'), ENT_NOQUOTES) . ": " . $send_rem_log['number_failed_emails'];?></span><br>
100 <span class="text"><?php echo htmlspecialchars(xl('Total successful reminders sent via phone'), ENT_NOQUOTES) . ": " . $send_rem_log['number_success_calls'];?></span><br>
101 <span class="text"><?php echo htmlspecialchars(xl('Total failed reminders sent via phone'), ENT_NOQUOTES) . ": " . $send_rem_log['number_unchanged_reminders'];?></span><br>
103 <br><span class="text"><?php echo htmlspecialchars(xl('(Email delivery is immediate, while automated VOIP is sent to the service provider for further processing.)'), ENT_NOQUOTES)?></span><br>
104 <?php } // end of ($results_log['type'] != "process_reminders") ?>
106 <?php if (report_id) { ?>
107 <br><input type="button" value="<?php echo htmlspecialchars(xl('Back'), ENT_QUOTES); ?>" onClick="top.restoreSession(); window.open('../reports/report_results.php','_self',false)"><br><br><br>
108 <?php } else { ?>
109 <br><input type="button" value="<?php echo htmlspecialchars(xl('Close'), ENT_QUOTES); ?>" onClick="window.close()"><br><br><br>
110 <?php } ?>
112 </td>
113 </tr>
114 </table>
115 <br><br>
116 </body>
117 </html>