function get_patient_balance($pid) {
if ($GLOBALS['oer_config']['ws_accounting']['enabled'] === 2) {
$brow = sqlQuery("SELECT SUM(fee) AS amount FROM billing WHERE " .
"pid = ? AND billed = 1 AND activity = 1", array($pid) );
$srow = sqlQuery("SELECT SUM(fee) AS amount FROM drug_sales WHERE " .
"pid = ?", array($pid) );
$drow = sqlQuery("SELECT SUM(pay_amount) AS payments, " .
"SUM(adj_amount) AS adjustments FROM ar_activity WHERE " .
"pid = ?", array($pid) );
return sprintf('%01.2f', $brow['amount'] + $srow['amount']
- $drow['payments'] - $drow['adjustments']);
}
以上是我正在使用的功能。在此函数中,$brow 从帐单表中创建一个数组。在这个数组中有负数。我希望能够从 SUM(fee) AS 金额中排除这些数字,以便我只加总正数。