From 1af254d2657066f93304af94e2ce1fdd5f2f6515 Mon Sep 17 00:00:00 2001 From: sunsetsystems Date: Sat, 15 Jul 2006 20:26:09 +0000 Subject: [PATCH] add ability to report on payment method --- accounting/ws_server.pl | 12 +- accounting/ws_server_26.pl | 15 +- interface/patient_file/pos_checkout.php | 10 +- interface/reports/receipts_by_method_report.php | 205 ++++++++++++++++++++++++ templates/report/general_default.html | 13 +- 5 files changed, 243 insertions(+), 12 deletions(-) create mode 100644 interface/reports/receipts_by_method_report.php diff --git a/accounting/ws_server.pl b/accounting/ws_server.pl index 1dbb978ee..8a2b5e71c 100755 --- a/accounting/ws_server.pl +++ b/accounting/ws_server.pl @@ -204,8 +204,16 @@ sub rpc_add_invoice { if($$line_item{'itemtext'} =~ /COPAY/){ $form->{"datepaid_$j"} = "$mm-$dd-$yy"; - $form->{"source_$j"} = "Co-pay"; - $form->{"memo_$j"} ='Co-pay'; + # For copays we use a dummy procedure code because it may be applicable + # to multiple procedures during the visit. + $form->{"memo_$j"} = 'Co-pay'; + # Put the payment method and check number in the source field if they are + # present (i.e. from pos_checkout.php). + if ($$line_item{'itemtext'} =~ /^COPAY:([A-Z].*)$/) { + $form->{"source_$j"} = $1; + } else { + $form->{"source_$j"} = 'Co-pay'; + } $form->{"paid_$j"} = abs($$line_item{'price'}); $form->{"AR_paid_$j"} = "$oemr_cash_acc" . "--"; $j++; diff --git a/accounting/ws_server_26.pl b/accounting/ws_server_26.pl index c2b2f009c..fc89bc413 100755 --- a/accounting/ws_server_26.pl +++ b/accounting/ws_server_26.pl @@ -213,16 +213,23 @@ sub rpc_add_invoice foreach my $line_item (@$items) { - if($$line_item{'itemtext'} =~ /COPAY/){ + if ($$line_item{'itemtext'} =~ /COPAY/) { $form->{"datepaid_$j"} = "$mm-$dd-$yy"; - $form->{"source_$j"} = "Co-pay"; - $form->{"memo_$j"} ='Co-pay'; + # For copays we use a dummy procedure code because it may be applicable + # to multiple procedures during the visit. + $form->{"memo_$j"} = 'Co-pay'; + # Put the payment method and check number in the source field if they are + # present (i.e. from pos_checkout.php). + if ($$line_item{'itemtext'} =~ /^COPAY:([A-Z].*)$/) { + $form->{"source_$j"} = $1; + } else { + $form->{"source_$j"} = 'Co-pay'; + } $form->{"paid_$j"} = abs($$line_item{'price'}); $form->{"AR_paid_$j"} = "$oemr_cash_acc" . "--"; $j++; } else{ - my $chart_id = 0; my $query = qq|SELECT id FROM chart WHERE accno = ?|; my $eth = $dbh->prepare($query) || die "Failed to prepare chart query"; diff --git a/interface/patient_file/pos_checkout.php b/interface/patient_file/pos_checkout.php index d283f920a..b974e875c 100644 --- a/interface/patient_file/pos_checkout.php +++ b/interface/patient_file/pos_checkout.php @@ -128,7 +128,8 @@ function invoice_add_line_item(& $invoice_info, $code_type, $code, { $tii = array(); $tii['maincode'] = $code; - $tii['itemtext'] = "$code_type:$code $code_text"; + $tii['itemtext'] = "$code_type:$code"; + if ($code_text) $tii['itemtext'] .= " $code_text"; $tii['qty'] = 1; $tii['price'] = sprintf("%01.2f", $amount); $tii['glaccountid'] = $GLOBALS['oer_config']['ws_accounting']['income_acct']; @@ -272,9 +273,11 @@ function invoice_post(& $invoice_info) $row = SLGetRow($atres, $irow); $amount = sprintf('%01.2f', $row['amount']); // negative $charges += $amount; + $rowsource = $row['source']; + if (strtolower($rowsource) == 'co-pay') $rowsource = ''; echo " \n"; echo " " . $row['transdate'] . "\n"; - echo " Payment " . $row['source'] . "\n"; + echo " Payment $rowsource\n"; echo " $amount\n"; echo " \n"; } @@ -392,8 +395,7 @@ function invoice_post(& $invoice_info) } if ($_POST['form_amount']) { - $paydesc = 'Received at time of visit'; - if ($_POST['form_source']) $paydesc .= ' (' . $_POST['form_source'] . ')'; + $paydesc = $_POST['form_source'] ? $_POST['form_source'] : ''; $msg = invoice_add_line_item($invoice_info, 'COPAY', $_POST['form_method'], $paydesc, diff --git a/interface/reports/receipts_by_method_report.php b/interface/reports/receipts_by_method_report.php new file mode 100644 index 000000000..127534a3b --- /dev/null +++ b/interface/reports/receipts_by_method_report.php @@ -0,0 +1,205 @@ + + // + // This program is free software; you can redistribute it and/or + // modify it under the terms of the GNU General Public License + // as published by the Free Software Foundation; either version 2 + // of the License, or (at your option) any later version. + + // This is a report of receipts by payment method. It's most useful for + // sites using pos_checkout.php (e.g. weight loss clinics) because this + // plugs a payment method like Cash, Check, VISA, etc. into the "source" + // column of the SQL-Ledger acc_trans table. + + include_once("../globals.php"); + include_once("../../library/patient.inc"); + include_once("../../library/sql-ledger.inc"); + include_once("../../library/acl.inc"); + + function bucks($amount) { + if ($amount) + printf("%.2f", $amount); + } + + if (! acl_check('acct', 'rep')) die(xl("Unauthorized access.")); + + SLConnect(); + + $form_from_date = fixDate($_POST['form_from_date'], date('Y-m-d')); + $form_to_date = fixDate($_POST['form_to_date'] , date('Y-m-d')); + $form_use_edate = $_POST['form_use_edate']; +?> + + +<?xl('Receipts by Payment Method','e')?> + + + +
+ +

+ +
+ + + + + + + + + + + +
+   +   + +  To: + +   + > +   + +
+
+ + + + + + + + + + += '$from_date' and " . + "ar.transdate <= '$to_date'"; + } else { + $query .= "acc_trans.transdate >= '$from_date' and " . + "acc_trans.transdate <= '$to_date'"; + } + + $query .= " order by acc_trans.source, acc_trans.transdate, ar.invnumber, acc_trans.memo"; + + echo "\n"; + + $t_res = SLQuery($query); + if ($sl_err) die($sl_err); + + $paymethod = ""; + $paymethodleft = ""; + $methodtotal = 0; + $grandtotal = 0; + + for ($irow = 0; $irow < SLRowCount($t_res); ++$irow) { + $row = SLGetRow($t_res, $irow); + $rowamount = 0 - $row['amount']; + + // Extract only the first word as the payment method because any following + // text will be some petty detail like a check number. + $rowmethod = substr($row['source'], 0, strcspn($row['source'], ' /')); + if (! $rowmethod) $rowmethod = 'Unknown'; + + if ($paymethod != $rowmethod) { + if ($paymethod) { + // Print method total. +?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + +
+ + + +
+ + + + + + + + + +
+ + + +
+ + + +
+
+
+ + diff --git a/templates/report/general_default.html b/templates/report/general_default.html index ded95e2ee..072997399 100644 --- a/templates/report/general_default.html +++ b/templates/report/general_default.html @@ -38,15 +38,24 @@ function dopopup(aurl) {
Appointments-Encounters Report
+ +{php} if (! $GLOBALS['simplified_demographics']) { {/php} Patient Insurance Distribution Report
Indigent Patients Report
-Front Office Receipts Report -
Unique Seen Patients Report
+{php} } {/php} + +{php} if (! $GLOBALS['weight_loss_clinic']) { {/php} +Front Office Receipts Report +
+{php} } {/php} + Prescriptions Report +
+Receipts by Payment Method Report {php} if ($GLOBALS['athletic_team']) { echo "
\n"; -- 2.11.4.GIT