added appointments-encounters report
[openemr.git] / library / billing.inc
blobe16fab33f0c4be2ba379d155d4991d08140e1464
1 <?php
3 require_once("{$GLOBALS['srcdir']}/sql.inc");
5 function getBillingById ($id, $cols = "*")
7         return sqlQuery("select $cols from billing where id='$id' and activity=1 order by date DESC limit 0,1");
10 function getBillingByPid ($pid, $cols = "*")
12         return  sqlQuery("select $cols from billing where pid ='$pid' and activity=1 order by date DESC limit 0,1");
15 function getBillingByEncounter ($pid,$encounter, $cols = "code_type, code, code_text")
17         $res = sqlStatement("select $cols from billing where encounter = '$encounter' and pid='$pid' and activity=1 order by code_type, date ASC");
19         for($iter=0; $row=sqlFetchArray($res); $iter++)
20         {
21                 $all[$iter] = $row;
22         }
23         return $all;
26 function addBilling($encounter_id, $code_type, $code, $code_text, $pid, $authorized = "0",$provider,$modifier="",$units="",$fee="0.00")
28         $sql = "insert into billing (date, encounter, code_type, code, code_text, pid, authorized, user, groupname,activity,billed,provider_id,modifier,units,fee) values (NOW(), '$encounter_id', '$code_type', '$code', '$code_text', '$pid', '$authorized', '" . $_SESSION['authId'] . "', '" . $_SESSION['authProvider'] . "',1,0,$provider,'$modifier','$units','$fee')";
29         
30         return sqlInsert($sql);
31         
34 function authorizeBilling($id, $authorized = "1")
36         sqlQuery("update billing set authorized = '$authorized' where id = '$id'");
39 function deleteBilling($id)
41         sqlStatement("update billing set activity = 0 where id = '$id'");
43 function clearBilling($id)
45         sqlStatement("update billing set justify = '' where id = '$id'");