ioncycle wrote on Monday, June 28, 2010:
I fixed printPatientBilling() in report.inc that’s used in custom_report.php for making billing reports under Medical Reports
Before it was spitting out all of the deleted bills as well.
report.inc
function printPatientBilling($pid) { //added AND activity='1'
$res = sqlStatement("select * from billing where pid='$pid' AND activity='1' order by date");
while($result = sqlFetchArray($res)) {
echo "<span class=bold>" . date("Y-m-d",strtotime($result{"date"})) . " : </span>";
echo "<span class=text>(".$result{"code_type"}.") " . $result{"code"} . " - ". $result['code_text']."</span>";
echo "<br>\n";
}
}
Plus I fixed custom_report.php code that fixes the broken Subtotal,Paid,Total code for the billing report, Part of this is in billing.inc
I added an array and removed the LIMIT so it doesn’t stop at 1.
billing.inc
function getBillingByPid ($pid, $cols = "*")
{
$res = sqlStatement("select $cols from billing where pid ='$pid' and activity=1 order by date DESC");
for($iter=0; $row=sqlFetchArray($res); $iter++)
{
$all[$iter] = $row;
}
return $all;
}
custom_report.php
} elseif ($val == "billing") {
echo "<hr />";
echo "<div class='text billing'>";
print "<h1>".xl('Billing Information').":</h1>";
if(empty($patient)){ $patient = array(); }
printPatientBilling($pid);
$billings = array();
echo "<table>";
$billing = getBillingByPid($pid); //had to fix billing.inc
if ($billing == null) { echo "<b>-- No bills to report.</b>";
return; }
echo "<tr><td width='400' class='bold'>Code</td><td class='bold'>".xl('Fee')."</td></tr>\n";
foreach ($billing as $b) {
echo "<tr>\n";
echo "<td class=text>";
echo $b['code_type'] . ":\t" . $b['code'] . " ". $b['modifier'] . " " . $b['code_text'] . " ";
echo "</td>\n";
echo "<td class=text>";
echo $b['fee'];
echo "</td>\n";
echo "</tr>\n";
$total += $b['fee'];
if ($b['code_type'] == "COPAY") {
$copays += $b['fee'];
}
}
echo "<tr><td> </td></tr>";
echo "<tr><td class=bold>".xl('Sub-Total')."</td><td class=text>" . sprintf("%0.2f",$total + abs($copays)) . "</td></tr>";
echo "<tr><td class=bold>".xl('Paid')."</td><td class=text>" . sprintf("%0.2f",abs($copays)) . "</td></tr>";
echo "<tr><td class=bold>".xl('Total')."</td><td class=text>" . sprintf("%0.2f",$total) . "</td></tr>";
echo "</table>";
echo "<pre>";
echo "</pre>";
echo "</div>\n"; // end of billing DIV