5 * @author Cristian NAVALICI (lemonsoftware [..] gmail [.] com)
9 require_once('DBC_cfunctions.php');
10 require_once('DBC_functions.php');
11 require_once('DBC_decisiontree.php');
12 require_once('DBC_validations.php');
16 // ----------------------------------------------------------------------------
23 function dc_yearly_closing() {
27 // take all opened DBC
28 $r = mysql_query("SELECT * FROM cl_axes ca JOIN cl_careroute_numbers ccn ON ca.ax_ztn = ccn.cn_ztn
29 WHERE ca.ax_open = 1");
31 while ( $row = mysql_fetch_array($r) ) {
32 $pid = $row['cn_pid'];
33 $dbcid = $row['ax_id'];
34 $today = date('Y-m-d');
36 // and calculate the age
37 $age = df_dbc_age($dbcid);
39 $rfsum = 0; // reset the rfsum!
40 dt_main(1, $dbcid, $odate);
41 $z = dt_whatproductgroep($rfsum, $odate);
44 $gafstr = unserialize($row['ax_as5']);
45 $gaf['gaf1'] = $gafstr['gaf1'];
46 $gaf['gaf2'] = preg_replace('/_01/', '_02', $gaf['gaf1']);
47 $gaf['gaf3'] = preg_replace('/_01/', '_03', $gaf['gaf1']);
49 $lastenc = last_encounter($pid);
51 $fe = future_events($pid, $today); // any future events after today?
53 $have_followup = ( $fe ) ?
1 : 0;
55 echo "$pid($dbcid) - $fe - LAST: {$lastenc['date']} F: $have_followup\n";
56 $newid = close_dbc($have_followup, $pcode, '180101', '110003', $gaf, $dbcid, $today, $pid);
59 df_cronlog("$today: DBC id: $dbcid (PID: $pid) was duplicated with DBC id: $newid ");
61 df_cronlog("$today: DBC id: $dbcid (PID: $pid) was closed without a followup. ");
67 //-----------------------------------------------------------------------------
71 make the connections to openemr database
72 the variables are taken from sqlconf.php
77 function dc_connect() {
78 require_once(dirname(__FILE__
) . '/sqlconf.php');
79 global $host, $login, $pass, $dbase;
81 $link = mysql_connect($host, $login, $pass);
83 die('Could not connect: ' . mysql_error());
86 mysql_query("USE " . $dbase);