[Fixed] Medical Report for Billing

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'] . "&nbsp;". $b['modifier'] . "&nbsp;&nbsp;&nbsp;" . $b['code_text'] . "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
                        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>&nbsp;</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

bradymiller wrote on Wednesday, June 30, 2010:

hey,
What OS are you developing on. Would be nice  if you could make patches for these changes and put in the tracker->Code Review here on sourceforge to get into the openemr public codebase. Let us know if need help making a patch.
thanks,
brady

ioncycle wrote on Thursday, July 01, 2010:

Do I just add an artifact? I mainly use TourtiseSVN on Wondows.

bradymiller wrote on Friday, July 02, 2010:

hey,

Check out our new developer page:
http://www.openmedsoftware.org/wiki/New_Developer_Information

For code submission, rec making an artifact in ‘Code Review’ tracker and then announcing it here also. Windows is tough to produce patches (perhaps tortoiseSVN can do this for you??), which is one of the reasons we have an openemr git repository on github.com; then can use tortoiseGIT, and easy to make patches and even simply place them on your github repository for us to test/commit.

If your having problems producing patches in windows, then can simply upload the entire file that you modified, but if do this then need to ensure the file is based on the most recent code. It’s generally best anyways to develop to the most current code (development tip/master), to ensure your changes get into the codebase forever (then can port it backwards to 3.2).

-brady

ioncycle wrote on Monday, July 05, 2010:

i also can upload on my MAC at work but I will try TourtiseSVN first

I will submit more code.
I fixed the New Encounter submission as it was defaulting to the current logged in person and not even an authorized Provider. Now you can select the Provider in a drop down menu on either NEW or UPDATE in the New Encounter Form.