0
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(費用)AS金額中排除這些數字,以便我只將正數總計加起來。篩選數組中的負數sql
做到了這一點。謝謝 – user1846439