Here is the code i tried,Please have a look at once and let me guide,if any issues on this code.I don’t have enough time to submit this on github. please don’t mistake me
$OE_SITES_BASE = "../../sites";
$dh = opendir($OE_SITES_BASE);
//echo $dh;
if (!$dh) die("Cannot read directory '$OE_SITES_BASE'.");
$siteslist = array();
while (false !== ($sfname = readdir($dh))) {
if (substr($sfname, 0, 1) == '.') continue;
if ($sfname == 'CVS' ) continue;
$sitedir = "$OE_SITES_BASE/$sfname";
if (!is_dir($sitedir) ) continue;
if (!is_file("$sitedir/sqlconf.php")) continue;
$siteslist[] = $sfname;
}
closedir($dh);
ksort($siteslist);
if($_GET['site']!='')
{
//cron_email_notification.php code
}
$total_sites=count($siteslist);
$numeral=$_GET['numeral']; //used to nesting the loop
if($total_sites>$numeral)
{
if($numeral=='')
$numeral=0;
else
$numeral++;
//stop incremental looping redirection while the number of sites and the current site is equal
if($total_sites==$numeral)
{
die;
}
//next site url for redirection
$url="/cron_email_notification.php?site=".$siteslist[$numeral]."&numeral=".$numeral;
//header in php throws unexpected break somewhere. it caused to go through javascript
?>
<script language="Javascript">
location.href="<?php echo $url; ?>";
</script>
<?php
}
Brady,
When we run cron_email_notification.php from cron job,it collects all sites from openemr/sites folder then it sends the reminders to all patient one by one site
Here is simple scenario
site one(Send all reminders) => Site2 (Send all reminders) => Site3 (Send all reminders)
Does it work?
My initial thoughts are that we should have a generic method within the php command line scripts for OpenEMR that do the following by utilizing a parameter when calling the script:
1. If no parameter is entered, then set $_GET to ‘default’
2. If the ‘ALL_SITES’ parameter is given, then do what you are doing and cycle through them all
3. If a site name is given as a parameter, then only do that site
If we had a mechanism like that, then we’d have a nice generic way to support command line scripts.
To take this further, I think I’d do the following:
1. For the command line scripts, simply support a parameter that brings the site in (so if no parameter, use ‘default’ and if a parameter then set this to the site).
2. Then I’d make a script called multsite_process_scripts which takes one parameter, which is the script names (ie. the scripts in number one above).This script could then iterate through all the different sites and run the above script for each. This script would be a general purpose script that could be used on any of the other command line scripts.
No time for me to do this(I’m just a volunteer with limited resources), but I’m glad to provide feedback/guidance/testing if you choose to work on this(another option is hiring a pro). The first step is getting a github repo going; here’s a tutorial on setting this up: http://www.open-emr.org/wiki/index.php/Git_for_dummies