5 * LICENSE: This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
17 * @author Brady Miller <brady.g.miller@gmail.com>
18 * @link http://www.open-emr.org
21 //INCLUDES, DO ANY ACTIONS, THEN GET OUR DATA
22 include_once("../globals.php");
23 include_once("$srcdir/registry.inc");
24 include_once("../../library/acl.inc");
25 include_once("batchcom.inc.php");
28 $thisauth = acl_check('admin', 'batchcom');
31 echo "<html>\n<body>\n";
32 echo "<p>".xl('You are not authorized for this.','','','</p>')."\n";
33 echo "</body>\n</html>\n";
37 // menu arrays (done this way so it's easier to validate input on validate selections)
38 $choices=Array (xl('CSV File'),xl('Email'),xl('Phone call list'));
39 $gender=Array (xl('Any'),xl('Male'),xl('Female'));
40 $hipaa=Array (xl('NO'),xl('YES'));
41 $sort_by=Array (xl('Zip Code')=>'patient_data.postal_code',xl('Last Name')=>'patient_data.lname',xl('Appointment Date')=>'last_ap' );
44 if ($_POST['form_action']=='Process') {
45 //validation uses the functions in batchcom.inc.php
47 if (!check_date_format($_POST['app_s'])) $form_err.=xl('Date format for "appointment start" is not valid','','<br>');
48 if (!check_date_format($_POST['app_e'])) $form_err.=xl('Date format for "appointment end" is not valid','','<br>');
49 if (!check_date_format($_POST['seen_since'])) $form_err.=xl('Date format for "seen since" is not valid','','<br>');
50 if (!check_date_format($_POST['not_seen_since'])) $form_err.=xl('Date format for "not seen since" is not valid','','<br>');
52 if (!check_age($_POST['age_from'])) $form_err.=xl('Age format for "age from" is not valid','','<br>');
53 if (!check_age($_POST['age_upto'])) $form_err.=xl('Age format for "age up to" is not valid','','<br>');
54 // validate selections
55 if (!check_select($_POST['gender'],$gender)) $form_err.=xl('Error in "Gender" selection','','<br>');
56 if (!check_select($_POST['process_type'],$choices)) $form_err.=xl('Error in "Process" selection','','<br>');
57 if (!check_select($_POST['hipaa_choice'],$hipaa)) $form_err.=xl('Error in "HIPAA" selection','','<br>');
58 if (!check_select($_POST['sort_by'],$sort_by)) $form_err.=xl('Error in "Sort By" selection','','<br>');
60 if (!check_yes_no ($_POST['and_or_gender'])) $form_err.=xl('Error in YES or NO option','','<br>');
61 if (!check_yes_no ($_POST['and_or_app_within'])) $form_err.=xl('Error in YES or NO option','','<br>');
62 if (!check_yes_no ($_POST['and_or_seen_since'])) $form_err.=xl('Error in YES or NO option','','<br>');
63 if (!check_yes_no ($_POST['and_or_not_seen_since'])) $form_err.=xl('Error in YES or NO option','','<br>');
69 $sql="select patient_data.*, cal_events.pc_eventDate as next_appt,cal_events.pc_startTime as appt_start_time,cal_date.last_appt,forms.last_visit from patient_data left outer join openemr_postcalendar_events as cal_events on patient_data.pid=cal_events.pc_pid and curdate() < cal_events.pc_eventDate left outer join (select pc_pid,max(pc_eventDate) as last_appt from openemr_postcalendar_events where curdate() >= pc_eventDate group by pc_pid ) as cal_date on cal_date.pc_pid=patient_data.pid left outer join (select pid,max(date) as last_visit from forms where curdate() >= date group by pid) as forms on forms.pid=patient_data.pid";
71 if ($_POST['app_s']!=0 AND $_POST['app_s']!='') {
72 $and=where_or_and ($and);
73 $sql_where_a=" $and cal_events.pc_eventDate > '".$_POST['app_s']."'";
75 if ($_POST['app_e']!=0 AND $_POST['app_e']!='') {
76 $and=where_or_and ($and);
77 $sql_where_a.=" $and cal_events.pc_endDate < '".$_POST['app_e']."'";
82 if ($_POST['seen_since']!=0 AND $_POST['seen_since']!='') {
83 $and=where_or_and ($and);
84 $sql.=" $and forms.date > '".$_POST['seen_since']."' " ;
86 if ($_POST['seen_upto']!=0 AND $_POST['not_seen_since']!='') {
87 $and=where_or_and ($and);
88 $sql.=" $and forms.date > '".$_POST['seen_since']."' " ;
92 if ($_POST['age_from']!=0 AND $_POST['age_from']!='') {
93 $and=where_or_and ($and);
94 $sql.=" $and DATEDIFF( CURDATE( ), patient_data.DOB )/ 365.25 >= '".$_POST['age_from']."' ";
96 if ($_POST['age_upto']!=0 AND $_POST['age_upto']!='') {
97 $and=where_or_and ($and);
98 $sql.=" $and DATEDIFF( CURDATE( ), patient_data.DOB )/ 365.25 <= '".$_POST['age_upto']."' ";
102 if ($_POST['gender']!='Any') {
103 $and=where_or_and ($and);
104 $sql.=" $and patient_data.sex='".$_POST['gender']."' ";
108 if ($_POST['hipaa_choice']!='NO') {
109 $and=where_or_and ($and);
110 $sql.=" $and patient_data.hipaa_mail='YES' ";
113 switch ($_POST['process_type']):
114 case $choices[1]: // Email
115 $and=where_or_and ($and);
116 $sql.=" $and patient_data.email IS NOT NULL ";
121 $sql.=' ORDER BY '.$_POST['sort_by'];
123 // send query for results.
124 $res = sqlStatement($sql);
127 if (sqlNumRows($res)==0){
131 <title
><?php
echo xlt('BatchCom'); ?
></title
>
132 <?php
html_header_show();?
>
133 <link rel
="stylesheet" href
="<?php echo $css_header;?>" type
="text/css">
134 <link rel
="stylesheet" href
="batchcom.css" type
="text/css">
135 <link rel
="stylesheet" href
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.min.css">
137 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-3-1-1/index.js"></script
>
138 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.full.min.js"></script
>
140 <script LANGUAGE
="JavaScript">
141 $
(document
).ready(function() {
142 $
('.datepicker').datetimepicker({
143 <?php
$datetimepicker_timepicker = false; ?
>
144 <?php
$datetimepicker_showseconds = false; ?
>
145 <?php
$datetimepicker_formatInput = false; ?
>
146 <?php
require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?
>
147 <?php
// can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
153 <body
class="body_top">
154 <!-- larry
's sms/email notification -->
155 <span class="title"><?php include_once("batch_navigation.php");?></span>
156 <!--- end of larry's insert
-->
157 <span
class="title"><?php
xl('Batch Communication Tool','e')?
></span
>
161 echo (xl('No results found, please try again.','','<br>'));
162 ?
> </div
></body
></html
> <?php
165 switch ($_POST['process_type']):
166 case $choices[0]: // CSV File
167 require_once ('batchCSV.php');
169 case $choices[1]: // Email
170 require_once ('batchEmail.php');
172 case $choices[2]: // Phone list
173 require_once ('batchPhoneList.php');
183 //START OUT OUR PAGE....
187 <title
><?php
echo xlt('BatchCom'); ?
></title
>
188 <?php
html_header_show();?
>
189 <link rel
="stylesheet" href
="<?php echo $css_header;?>" type
="text/css">
190 <link rel
="stylesheet" href
="batchcom.css" type
="text/css">
191 <link rel
="stylesheet" href
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.min.css">
193 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-3-1-1/index.js"></script
>
194 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.full.min.js"></script
>
196 <script LANGUAGE
="JavaScript">
197 $
(document
).ready(function() {
198 $
('.datepicker').datetimepicker({
199 <?php
$datetimepicker_timepicker = false; ?
>
200 <?php
$datetimepicker_showseconds = false; ?
>
201 <?php
$datetimepicker_formatInput = false; ?
>
202 <?php
require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?
>
203 <?php
// can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
209 <body
class="body_top">
210 <!-- larry
's sms/email notification -->
211 <span class="title"><?php include_once("batch_navigation.php");?></span>
212 <!--- end of larry's insert
-->
213 <span
class="title"><?php
xl('Batch Communication Tool','e')?
></span
>
216 <!-- for the popup date selector
-->
217 <div id
="overDiv" style
="position:absolute; visibility:hidden; z-index:1000;"></div
>
218 <FORM name
="select_form" METHOD
=POST ACTION
="" onsubmit
='return top.restoreSession()'>
220 <div
class="main_box">
221 <table
class="table" ><tr
><td
>
224 echo (xl('The following errors occurred')."<br>$form_err<br><br>");
227 xl('Process','e')?
>:</td
><td
><SELECT NAME
="process_type">
229 foreach ($choices as $value) {
230 echo ("<option>$value</option>");
234 <td
> 
;</td
><td
> 
;</td
>
237 <?php
xl('Overwrite HIPAA choice','e')?
> :</td
><td align
='left'><SELECT NAME
="hipaa_choice">
239 foreach ($hipaa as $value) {
240 echo ("<option>$value</option>");
244 <td
> 
;</td
><td
> 
;</td
>
246 <?php
xl('Age From','e')?
>:<INPUT TYPE
="text" size
="2" NAME
="age_from"></td
><td
> <?php
xl('Up to','e')?
>:<INPUT TYPE
="text" size
="2" NAME
="age_upto"></td
><td
>
247 <?php
xl('And','e')?
>:<INPUT TYPE
="radio" NAME
="and_or_gender" value
="AND" checked
>, <?php
xl('Or','e')?
>:<INPUT TYPE
="radio" NAME
="and_or_gender" value
="OR"></td
><td
>
248 <?php
xl('Gender','e')?
> :<SELECT NAME
="gender">
250 foreach ($gender as $value) {
251 echo ("<option>$value</option>");
257 <br
>Insurance
: <SELECT multiple NAME
="insurance" Rows
="10" cols
="20">
261 <?php
xl('And','e')?
>:<INPUT TYPE
="radio" NAME
="and_or_app_within" value
="AND" checked
>, <?php
xl('Or','e')?
>:<INPUT TYPE
="radio" NAME
="and_or_app_within" value
="OR"></td
><td
> <?php
xl('Appointment within','e')?
>:</td
><td
><INPUT TYPE
='text' size
='12' class='datepicker' NAME
='app_s'></td
><td
>
263 <?php
xl('And','e')?
> : <INPUT TYPE
='text' size
='12' class='datepicker' NAME
='app_e'></td
>
266 <?php
xl('And','e')?
>:<INPUT TYPE
="radio" NAME
="and_or_seen_since" value
="AND" checked
>, <?php
xl('Or','e')?
>:<INPUT TYPE
="radio" NAME
="and_or_seen_since" value
="OR"></td
><td
> <?php
xl('Seen since','e')?
> :</td
><td
><INPUT TYPE
='text' size
='12' class='datepicker' NAME
='seen_since'></td
>
270 <?php
xl('And','e')?
>:<INPUT TYPE
="radio" NAME
="and_or_not_seen_since" value
="AND" checked
>, <?php
xl('Or','e')?
>:<INPUT TYPE
="radio" NAME
="and_or_not_seen_since" value
="OR"></td
><td
> <?php
xl('Not seen since','e')?
> :</td
><td
><INPUT TYPE
='text' size
='12' class='datepicker' NAME
='not_seen_since'></td
>
273 <?php
xl('Sort by','e')?
> :</td
><td
><SELECT NAME
="sort_by">
275 foreach ($sort_by as $key => $value) {
276 echo ("<option value=\"".$value."\">$key</option>");
280 <td
> 
;</td
><td
> 
;</td
>
281 </tr
><tr
><td colspan
='3'>
282 (<?php
xl('Fill here only if sending email notification to patients','e')?
>)</td
>
283 <td
> 
;</td
><td
> 
;</td
><td
> 
;</td
>
285 <?php
xl('Email Sender','e')?
> :</td
><td
><INPUT TYPE
="text" NAME
="email_sender" value
="your@example.com"></td
>
286 <td
> 
;</td
><td
> 
;</td
>
288 <?php
xl('Email Subject','e')?
>:</td
><td
><INPUT TYPE
="text" NAME
="email_subject" value
="From your clinic"></td
>
289 <td
> 
;</td
><td
> 
;</td
>
290 </tr
><tr
><td colspan
='3'>
291 <?php
echo xlt('Email Text, Usable Tag: ***NAME*** , i.e. Dear ***NAME***{{Do Not translate the ***NAME*** elements of this constant.}}')?
></td
>
292 <td
> 
;</td
><td
> 
;</td
><td
> 
;</td
></tr
>
294 <TEXTAREA NAME
="email_body" ROWS
="8" COLS
="40"></TEXTAREA
></td
>
295 <td
> 
;</td
><td
> 
;</td
><td
> 
;</td
>
298 <INPUT TYPE
="submit" name
="form_action" value
=<?php
xl('Process','e','\'','\''); ?
>> </td
><td
><?php
xl('Process takes some time','e')?
></td
> <td
> 
;</td
><td
> 
;</td
></tr
>