2 require_once("{$GLOBALS['srcdir']}/sql.inc");
4 //date must be in nice format (e.g. 2002-07-11)
6 function getBillsBy($date, $qtype = "day", $auth="%", $cols = "date,pid,code_type,code,user,authorized")
9 $res = sqlStatement("select $cols from billing order by date ASC");
11 elseif ($qtype == "day") {
12 $res = sqlStatement("select $cols from billing where date like '$date' order by date ASC");
14 elseif ($qtype == "month") {
15 $m = substr($date,5,2);
16 $y = substr($date,0,4);
17 $res = sqlStatement("select $cols from billing where MONTH(date) = '$m' and YEAR(date) = '$y' ORDER by date ASC");
19 elseif ($qtype == "year") {
20 $y = substr($date,0,4);
21 $res = sqlStatement("select $cols from billing where YEAR(date) = '$y' ORDER by date ASC");
24 for($iter=0; $row=sqlFetchArray($res); $iter++)
34 function getBillsBetween($date, $date2, $auth="%", $unbilled, $code_type, $cols = "id,date,pid,code_type,code,user,authorized,x12_partner_id")
37 $billstring = "billed = '0'";
38 if ($unbilled == "0") {
39 //3 is an error condition
40 $billstring = "billed = '0' or (billed = '1' and bill_process = '3')";
43 $billstring = "billed = '1'";
45 $sql = "select * from billing where date >= '$date' and date <= '$date2 23:59:59' and authorized like '$auth' and ($billstring) and code_type like '$code_type' and activity = 1 order by encounter,pid,code_type,code ASC";
47 $res = sqlStatement($sql);
48 //print "select $cols from billing where date >= '$date' and date <= '$date2 23:59:59' and authorized like '$auth' and billed like '$unbilled' and code_type like '$code_type' order by pid,date ASC";
50 for($iter=0; $row=sqlFetchArray($res); $iter++)
59 function getBillsListBetween($date, $date2, $auth="%", $unbilled, $code_type, $cols = "id,date,pid,code_type,code,user")
61 $billstring = "billed = '0'";
62 if ($unbilled == "0") {
63 //3 is an error condition
64 $billstring = "billed = '0' or (billed = '1' and bill_process = '3')";
67 $billstring = "billed = '1'";
69 $sql = "select $cols from billing where date >= '$date' and date <= '$date2 23:59:59' and authorized like '$auth' and ($billstring) and code_type like '$code_type' and activity = 1 order by pid,date ASC";
71 $res = sqlStatement($sql);
72 //print "select $cols from billing where date >= '$date' and date <= '$date2 23:59:59' and authorized like '$auth' and billed like '$unbilled' and code_type like '$code_type' order by pid,date ASC";
74 for($iter=0; $row=sqlFetchArray($res); $iter++)
76 $string .= $row{"id"}.",";
78 $string = substr($string,0,strlen($string)-1);
84 function billCodesBetween($date, $date2, $auth="%", $code_type)
86 sqlStatement("update billing set billed=1 where date >= '$date' and date <= '$date2 23:59:59' and authorized like '$auth' and code_type like '$code_type'");
88 function billCodesList($list,$skip = "()") {
93 sqlStatement("update billing set billed=1 where id in $list");
95 sqlStatement("update billing set billed=1 where id in $list and id not in $skip");
100 function getCodeTypes () {
101 $res = sqlStatement("select distinct code_type from billing order by code_type");
103 for($iter=0; $row=sqlFetchArray($res); $iter++)