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 の金額から除外して、正の数値の合計のみを合計できるようにしたいと考えています。