3 * This provides for manual posting of EOBs. It is invoked from
4 * sl_eob_search.php. For automated (X12 835) remittance posting
5 * see sl_eob_process.php.
7 * Copyright (C) 2005-2016 Rod Roark <rod@sunsetsystems.com>
9 * LICENSE: This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
21 * @author Rod Roark <rod@sunsetsystems.com>
22 * @author Roberto Vasquez <robertogagliotta@gmail.com>
23 * @author Terry Hill <terry@lillysystems.com>
24 * @author Jerry Padgett <sjpadgett@gmail.com>
25 * @link http://www.open-emr.org
29 require_once("../globals.php");
30 require_once("$srcdir/log.inc");
31 require_once("$srcdir/patient.inc");
32 require_once("$srcdir/forms.inc");
33 require_once("$srcdir/sl_eob.inc.php");
34 require_once("$srcdir/invoice_summary.inc.php");
35 require_once("../../custom/code_types.inc.php");
37 use OpenEMR\Core\Header
;
39 $debug = 0; // set to 1 for debugging mode
40 $save_stay = $_REQUEST['form_save'] == '1' ?
true : false;
42 // If we permit deletion of transactions. Might change this later.
47 // Format money for display.
49 function bucks($amount)
52 return sprintf("%.2f", $amount);
56 // Delete rows, with logging, for the specified table using the
57 // specified WHERE clause. Borrowed from deleter.php.
59 function row_delete($table, $where)
61 $tres = sqlStatement("SELECT * FROM $table WHERE $where");
63 while ($trow = sqlFetchArray($tres)) {
65 foreach ($trow as $key => $value) {
66 if (!$value ||
$value == '0000-00-00 00:00:00') {
74 $logstring .= $key . "='" . addslashes($value) . "'";
77 newEvent("delete", $_SESSION['authUser'], $_SESSION['authProvider'], 1, "$table: $logstring");
81 if ($count) { // Lets not echo the query for stay and save
82 $query = "DELETE FROM $table WHERE $where";
90 <?php Header
::setupHeader(['datetime-picker']); ?
>
91 <title
><?php
echo xlt('EOB Posting - Invoice') ?
></title
>
92 <script language
="JavaScript">
93 var adjDisable
= opener
.document
.forms
[0].posting_adj_disable
.checked
;
95 // An insurance radio button is selected.
96 function setins(istr
) {
100 function refreshOpener() {
101 opener
.location
.reload();
105 // Compute an adjustment that writes off the balance:
106 function writeoff(code
) {
107 var f
= document
.forms
[0];
108 var belement
= f
['form_line[' + code +
'][bal]'];
109 var pelement
= f
['form_line[' + code +
'][pay]'];
110 var aelement
= f
['form_line[' + code +
'][adj]'];
111 var relement
= f
['form_line[' + code +
'][reason]'];
112 var tmp
= belement
.value
- pelement
.value
;
113 aelement
.value
= Number(tmp
).toFixed(2);
114 if (aelement
.value
&& !relement
.value
) relement
.selectedIndex
= 1;
118 // Onsubmit handler. A good excuse to write some JavaScript.
119 function validate(f
) {
122 adjDisable
= opener
.document
.forms
[0].posting_adj_disable
.checked
;
124 for (var i
= 0; i
< f
.elements
.length
; ++i
) {
125 let ename
= f
.elements
[i
].name
;
127 if (ename
.substring(0, 9) == 'form_del[') {
128 if (f
.elements
[i
].checked
) ++delcount
;
131 let pfxlen
= ename
.indexOf('[pay]');
132 if (pfxlen
< 0) continue;
133 let pfx
= ename
.substring(0, pfxlen
);
134 let code
= pfx
.substring(pfx
.indexOf('[') +
1, pfxlen
- 1);
135 let cPay
= parseFloat(f
[pfx +
'[pay]'].value
).toFixed(2);
136 let cAdjust
= parseFloat(f
[pfx +
'[adj]'].value
).toFixed(2);
138 if ((cPay
!= 0) || cAdjust
!= 0) {
142 if ((cAdjust
== 0 && f
[pfx +
'[reason]'].value
)) {
146 if ((cPay
!= 0) && isNaN(parseFloat(f
[pfx +
'[pay]'].value
))) {
147 alert('<?php echo xls('Payment value
for code
') ?>' + code +
'<?php echo xls(' is not a number
') ?>');
150 if ((cAdjust
!= 0) && isNaN(parseFloat(f
[pfx +
'[adj]'].value
))) {
151 alert('<?php echo xls('Adjustment value
for code
') ?>' + code +
'<?php echo xls(' is not a number
') ?>');
154 if ((cAdjust
!= 0) && !f
[pfx +
'[reason]'].value
) {
155 alert('<?php echo xls('Please select an adjustment reason
for code
') ?>' + code
);
158 // TBD: validate the date format
160 // Check if save is clicked with nothing to post.
161 if (allempty
&& delcount
=== 0) {
162 alert('<?php echo xls('Nothing to Post
! Please review entries
or use Cancel to
exit transaction
')?>');
165 // Demand confirmation if deleting anything.
167 if (!confirm('<?php echo xls('Really delete
'); ?> ' + delcount +
168 ' <?php echo xls('transactions
'); ?>?' +
169 ' <?php echo xls('This action will be logged
'); ?>!')
175 <!-- Get current date
-->
177 function getFormattedToday() {
178 let today
= new Date();
179 let dd
= today
.getDate();
180 let mm
= today
.getMonth() +
1; //January is 0!
181 let yyyy
= today
.getFullYear();
189 return (yyyy +
'-' + mm +
'-' + dd
);
192 <!-- Update Payment Fields
-->
194 function updateFields(payField
, adjField
, balField
, coPayField
, isFirstProcCode
) {
198 let coPayAmount
= 0.0;
200 // coPayFiled will be null if there is no co-pay entry in the fee sheet
202 coPayAmount
= coPayField
.value
;
204 // if balance field is 0.00, its value comes back as null, so check for nul-ness first
206 balAmount
= (balField
.value
) ? balField
.value
: 0;
208 payAmount
= (payField
.value
) ? payField
.value
: 0;
210 //alert('balance = >' + balAmount +'< payAmount = ' + payAmount + ' copay = ' + coPayAmount + ' isFirstProcCode = ' + isFirstProcCode);
212 // subtract the co-pay only from the first procedure code
213 if (isFirstProcCode
== 1)
214 balAmount
= parseFloat(balAmount
) +
parseFloat(coPayAmount
);
215 let adjDisable
= opener
.document
.forms
[0].posting_adj_disable
.checked
;
216 if (adjDisable
) return;
218 adjAmount
= balAmount
- payAmount
;
219 // Assign rounded adjustment value back to TextField
220 adjField
.value
= adjAmount
= Math
.round(adjAmount
* 100) / 100;
223 $
(document
).ready(function () {
224 $
('.datepicker').datetimepicker({
225 <?php
$datetimepicker_timepicker = false; ?
>
226 <?php
$datetimepicker_showseconds = false; ?
>
227 <?php
$datetimepicker_formatInput = false; ?
>
228 <?php
require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?
>
229 <?php
// can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
235 @media only screen
and (max
-width
: 768px
) {
238 text
-align
: left
!Important
;
247 .table
> tbody
> tr
> td
{
252 border
-bottom
: 1px black solid
;
256 @media
(min
-width
: 992px
) {
258 width
: 1000px
!Important
;
263 overflow-x: hidden !Important;
273 $trans_id = 0 +
$_GET['id'];
275 die(xlt("You cannot access this page directly."));
278 // A/R case, $trans_id matches form_encounter.id.
279 $ferow = sqlQuery("SELECT e.*, p.fname, p.mname, p.lname FROM form_encounter AS e, patient_data AS p WHERE e.id = ? AND p.pid = e.pid", array($trans_id));
281 die("There is no encounter with form_encounter.id = '" . text($trans_id) . "'.");
283 $patient_id = 0 +
$ferow['pid'];
284 $encounter_id = 0 +
$ferow['encounter'];
285 $svcdate = substr($ferow['date'], 0, 10);
286 $form_payer_id = 0 +
$_POST['form_payer_id'];
287 $form_reference = $_POST['form_reference'];
288 $form_check_date = fixDate($_POST['form_check_date'], date('Y-m-d'));
289 $form_deposit_date = fixDate($_POST['form_deposit_date'], $form_check_date);
290 $form_pay_total = 0 +
$_POST['form_pay_total'];
293 if (preg_match('/^Ins(\d)/i', $_POST['form_insurance'], $matches)) {
294 $payer_type = $matches[1];
297 if (($_POST['form_save'] ||
$_POST['form_cancel'])) {
298 if ($_POST['form_save']) {
299 if (!verifyCsrfToken($_POST["csrf_token_form"])) {
300 die(xlt('Authentication Error'));
304 echo "<p><b>" . xlt("This module is in test mode. The database will not be changed.") . "</b><p>\n";
307 $session_id = arGetSession($form_payer_id, $form_reference, $form_check_date, $form_deposit_date, $form_pay_total);
308 // The sl_eob_search page needs its invoice links modified to invoke
309 // javascript to load form parms for all the above and submit.
310 // At the same time that page would be modified to work off the
311 // openemr database exclusively.
312 // And back to the sl_eob_invoice page, I think we may want to move
313 // the source input fields from row level to header level.
315 // Handle deletes. row_delete() is borrowed from deleter.php.
316 if ($ALLOW_DELETE && !$debug) {
317 if (is_array($_POST['form_del'])) {
318 foreach ($_POST['form_del'] as $arseq => $dummy) {
319 row_delete("ar_activity", "pid = '" . add_escape_custom($patient_id) . "' AND " . "encounter = '" . add_escape_custom($encounter_id) . "' AND sequence_no = '" . add_escape_custom($arseq) . "'");
325 foreach ($_POST['form_line'] as $code => $cdata) {
326 $thispay = trim($cdata['pay']);
327 $thisadj = trim($cdata['adj']);
328 $thisins = trim($cdata['ins']);
329 $thiscodetype = trim($cdata['code_type']);
330 $reason = $cdata['reason'];
332 // Get the adjustment reason type. Possible values are:
333 // 1 = Charge adjustment
340 $tmp = sqlQuery("SELECT option_value FROM list_options WHERE list_id = 'adjreason' AND activity = 1 AND option_id = ?", array($reason));
341 if (empty($tmp['option_value'])) {
342 // This should not happen but if it does, apply old logic.
343 if (preg_match("/To copay/", $reason)) {
345 } elseif (preg_match("/To ded'ble/", $reason)) {
348 $info_msg .= xl("No adjustment reason type found for") . " \"$reason\". ";
350 $reason_type = $tmp['option_value'];
358 if (0.0 +
$thispay) {
359 arPostPayment($patient_id, $encounter_id, $session_id, $thispay, $code, $payer_type, '', $debug, '', $thiscodetype);
360 $paytotal +
= $thispay;
363 // Be sure to record adjustment reasons, even for zero adjustments if
364 // they happen to be comments.
365 if ((0.0 +
$thisadj) ||
366 ($reason && $reason_type == 5) ||
367 ($reason && ($reason_type > 1 && $reason_type < 6))) {
368 // "To copay" and "To ded'ble" need to become a comment in a zero
369 // adjustment, formatted just like sl_eob_process.php.
370 if ($reason_type == '2') {
371 $reason = $_POST['form_insurance'] . " coins: $thisadj";
373 } elseif ($reason_type == '3') {
374 $reason = $_POST['form_insurance'] . " dedbl: $thisadj";
376 } elseif ($reason_type == '4') {
377 $reason = $_POST['form_insurance'] . " ptresp: $thisadj $reason";
379 } elseif ($reason_type == '5') {
380 $reason = $_POST['form_insurance'] . " note: $thisadj $reason";
383 // An adjustment reason including "Ins" is assumed to be assigned by
384 // insurance, and in that case we identify which one by appending
385 // Ins1, Ins2 or Ins3.
386 if (strpos(strtolower($reason), 'ins') != false) {
387 $reason .= ' ' . $_POST['form_insurance'];
390 arPostAdjustment($patient_id, $encounter_id, $session_id, $thisadj, $code, $payer_type, $reason, $debug, '', $thiscodetype);
394 // Maintain which insurances are marked as finished.
396 $form_done = 0 +
$_POST['form_done'];
397 $form_stmt_count = 0 +
$_POST['form_stmt_count'];
398 sqlStatement("UPDATE form_encounter SET last_level_closed = ?, stmt_count = ? WHERE pid = ? AND encounter = ?", array($form_done, $form_stmt_count, $patient_id, $encounter_id));
400 if ($_POST['form_secondary']) {
401 arSetupSecondary($patient_id, $encounter_id, $debug);
403 echo "<script language='JavaScript'>\n";
404 echo " if (opener.document.forms[0] != undefined) {\n";
405 echo " if (opener.document.forms[0].form_amount) {\n";
406 echo " var tmp = opener.document.forms[0].form_amount.value - " . attr($paytotal) . ";\n";
407 echo " opener.document.forms[0].form_amount.value = Number(tmp).toFixed(2);\n";
411 echo "<script language='JavaScript'>\n";
414 echo " alert('" . addslashes($info_msg) . "');\n";
416 echo "opener.location.reload();";
417 if (!$debug && !$save_stay) {
418 echo " window.close();\n";
420 $reload_url = "sl_eob_invoice.php?id=" . attr(urlencode($trans_id));
421 echo "window.location.assign('" . $reload_url . "')";
423 echo "</script></body></html>\n";
429 // Get invoice charge details.
430 $codes = ar_get_invoice_summary($patient_id, $encounter_id, true);
431 $pdrow = sqlQuery("select billing_note from patient_data where pid = ? limit 1", array($patient_id));
434 <div
class="container">
436 <div
class="page-header">
437 <h2
><?php
echo xlt('EOB Invoice'); ?
></h2
>
441 <form action
='sl_eob_invoice.php?id=<?php echo attr(urlencode($trans_id)); ?>' method
='post'
442 onsubmit
='return validate(this)'>
443 <input type
="hidden" name
="csrf_token_form" value
="<?php echo attr(collectCsrfToken()); ?>"/>
445 <legend
><?php
echo xlt('Invoice Actions'); ?
></legend
>
446 <div
class="col-xs-12 oe-custom-line">
447 <div
class="col-xs-3">
448 <label
class="control-label" for="form_name"><?php
echo xlt('Patient'); ?
>:</label
>
449 <input type
="text" class="form-control" class="form-control" class="form-control" id
='form_name'
451 value
="<?php echo attr($ferow['fname']) . ' ' . attr($ferow['mname']) . ' ' . attr($ferow['lname']); ?>"
454 <div
class="col-xs-3">
455 <label
class="control-label" for="form_provider"><?php
echo xlt('Provider'); ?
>:</label
>
457 $tmp = sqlQuery("SELECT fname, mname, lname " .
458 "FROM users WHERE id = ?", array($ferow['provider_id']));
459 $provider = text($tmp['fname']) . ' ' . text($tmp['mname']) . ' ' . text($tmp['lname']);
460 $tmp = sqlQuery("SELECT bill_date FROM billing WHERE " .
461 "pid = ? AND encounter = ? AND " .
462 "activity = 1 ORDER BY fee DESC, id ASC LIMIT 1", array($patient_id, $encounter_id));
463 $billdate = substr(($tmp['bill_date'] . "Not Billed"), 0, 10);
465 <input type
="text" class="form-control" class="form-control" id
='form_provider'
466 name
='form_provider' value
="<?php echo attr($provider); ?>" disabled
>
468 <div
class="col-xs-2">
469 <label
class="control-label" for="form_invoice"><?php
echo xlt('Invoice'); ?
>:</label
>
470 <input type
="text" class="form-control" class="form-control" id
='form_provider'
471 name
='form_provider' value
='<?php echo attr($patient_id) . "." . attr($encounter_id); ?>'
474 <div
class="col-xs-2">
475 <label
class="control-label" for="svc_date"><?php
echo xlt('Svc Date'); ?
>:</label
>
476 <input type
="text" class="form-control" class="form-control" id
='svc_date' name
='form_provider'
477 value
='<?php echo attr($svcdate); ?>' disabled
>
479 <div
class="col-xs-2">
480 <label
class="control-label" for="insurance_name"><?php
echo xlt('Insurance'); ?
>:</label
>
482 for ($i = 1; $i <= 3; ++
$i) {
483 $payerid = arGetPayerID($patient_id, $svcdate, $i);
485 $tmp = sqlQuery("SELECT name FROM insurance_companies WHERE id = ?", array($payerid));
486 $insurance .= "$i: " . $tmp['name'] . "\n";
490 <textarea name
="insurance_name" id
="insurance_name" class="form-control" cols
="5" rows
="2"
491 readonly
><?php
echo attr($insurance); ?
></textarea
>
494 <div
class="col-xs-12 oe-custom-line">
495 <div
class="col-xs-3">
496 <label
class="control-label" for="form_stmt_count"><?php
echo xlt('Statements Sent'); ?
>
498 <input type
='text' name
='form_stmt_count' id
='form_stmt_count' class="form-control"
499 value
='<?php echo attr((0 + $ferow['stmt_count
'])); ?>'/>
501 <div
class="col-xs-3">
502 <label
class="control-label" for="form_reference"><?php
echo xlt('Check/EOB No.'); ?
>:</label
>
503 <input type
='text' name
='form_reference' id
='form_reference' class="form-control" value
=''/>
505 <div
class="col-xs-2">
506 <label
class="control-label" for="form_check_date"><?php
echo xlt('Check/EOB Date'); ?
>:</label
>
507 <input type
='text' name
='form_check_date' class='form-control datepicker' value
=''/>
509 <div
class="col-xs-2">
510 <label
class="control-label" for="form_deposit_date"><?php
echo xlt('Deposit Date'); ?
>:</label
>
511 <input type
='text' name
='form_deposit_date' id
='form_deposit_date'
512 class='form-control datepicker' value
=''/>
513 <input type
='hidden' name
='form_payer_id' value
=''/>
514 <input type
='hidden' name
='form_orig_reference' value
=''/>
515 <input type
='hidden' name
='form_orig_check_date' value
=''/>
516 <input type
='hidden' name
='form_orig_deposit_date' value
=''/>
517 <input type
='hidden' name
='form_pay_total' value
=''/>
520 <div
class="col-xs-12 oe-custom-line">
521 <div
class="col-xs-4">
522 <label
class="control-label" for="type_code"><?php
echo xlt('Now posting for'); ?
>:</label
>
523 <div style
="padding-left:15px">
525 // TBD: check the first not-done-with insurance, not always Ins1!
527 <label
class="radio-inline">
528 <input checked name
='form_insurance' onclick
='setins("Ins1")' type
='radio'
529 value
='Ins1'><?php
echo xlt('Ins1') ?
>
531 <label
class="radio-inline">
532 <input name
='form_insurance' onclick
='setins("Ins2")' type
='radio'
533 value
='Ins2'><?php
echo xlt('Ins2') ?
>
535 <label
class="radio-inline">
536 <input name
='form_insurance' onclick
='setins("Ins3")' type
='radio'
537 value
='Ins3'><?php
echo xlt('Ins3') ?
>
539 <label
class="radio-inline">
540 <input name
='form_insurance' onclick
='setins("Pt")' type
='radio'
541 value
='Pt'><?php
echo xlt('Patient') ?
>
544 // TBD: I think the following is unused and can be removed.
546 <input name
='form_eobs' type
='hidden' value
='<?php echo attr($arrow['shipvia
']) ?>'/>
549 <div
class="col-xs-4">
550 <label
class="control-label" for=""><?php
echo xlt('Done with'); ?
>:</label
>
551 <div style
="padding-left:15px">
553 // Write a checkbox for each insurance. It is to be checked when
554 // we no longer expect any payments from that company for the claim.
555 $last_level_closed = 0 +
$ferow['last_level_closed'];
556 foreach (array(0 => 'None', 1 => 'Ins1', 2 => 'Ins2', 3 => 'Ins3') as $key => $value) {
557 if ($key && !arGetPayerID($patient_id, $svcdate, $key)) {
560 $checked = ($last_level_closed == $key) ?
" checked" : "";
561 echo "<label class='radio-inline'>";
562 echo "<input type='radio' name='form_done' value='" . attr($key) . "'$checked />" . text($value);
568 <div
class="col-xs-4">
569 <label
class="control-label" for=""><?php
echo xlt('Secondary billing'); ?
>:</label
>
570 <div style
="padding-left:15px">
571 <label
class="checkbox-inline">
572 <input name
="form_secondary" type
="checkbox"
573 value
="1"><?php
echo xlt('Needs secondary billing') ?
>
581 <legend
><?php
echo xlt('Invoice Details'); ?
></legend
>
582 <div
class="table-responsive">
583 <table
class="table table-condensed">
586 <th
><?php
echo xlt('Code') ?
></th
>
587 <th align
="right"><?php
echo xlt('Charge') ?
></th
>
588 <th align
="right"><?php
echo xlt('Balance') ?
> 
;</th
>
589 <th
><?php
echo xlt('By/Source') ?
></th
>
590 <th
><?php
echo xlt('Date') ?
></th
>
591 <th
><?php
echo xlt('Pay') ?
></th
>
592 <th
><?php
echo xlt('Adjust') ?
></th
>
594 <th
><?php
echo xlt('Reason') ?
></th
>
596 if ($ALLOW_DELETE) { ?
>
597 <th
><?php
echo xlt('Del') ?
></th
>
603 $firstProcCodeIndex = -1;
605 foreach ($codes as $code => $cdata) {
609 // remember the index of the first entry whose code is not "CO-PAY", i.e. it's a legitimate proc code
610 if ($firstProcCodeIndex == -1 && strcmp($code, "CO-PAY") != 0) {
611 $firstProcCodeIndex = $encount;
614 // this sorts the details more or less chronologically:
615 ksort($cdata['dtl']);
616 foreach ($cdata['dtl'] as $dkey => $ddata) {
617 $ddate = substr($dkey, 0, 10);
618 if (preg_match('/^(\d\d\d\d)(\d\d)(\d\d)\s*$/', $ddate, $matches)) {
619 $ddate = $matches[1] . '-' . $matches[2] . '-' . $matches[3];
623 if ($ddata['chg'] != 0) {
624 if (isset($ddata['rsn'])) {
625 $tmpadj = 0 - $ddata['chg'];
627 $tmpchg = $ddata['chg'];
633 style
="background:<?php echo $dispcode ? 'lightyellow' : ''; ?>"><?php
echo text($dispcode);
634 $dispcode = "" ?
></td
>
635 <td
class="detail" class="detail"><?php
echo text(bucks($tmpchg)); ?
></td
>
636 <td
class="detail" class="detail"> 
;</td
>
639 if (isset($ddata['plv'])) {
640 if (!$ddata['plv']) {
643 echo 'Ins' . text($ddata['plv']) . '/';
646 echo text($ddata['src']);
649 <td
class="detail"><?php
echo text($ddate); ?
></td
>
650 <td
class="detail"><?php
echo text(bucks($ddata['pmt'])); ?
></td
>
651 <td
class="detail"><?php
echo text(bucks($tmpadj)); ?
></td
>
652 <td
class="detail"> 
;</td
>
653 <td
class="detail"><?php
echo text($ddata['rsn']); ?
></td
>
655 if ($ALLOW_DELETE) { ?
>
658 if (!empty($ddata['arseq'])) { ?
>
659 <input name
="form_del[<?php echo attr($ddata['arseq']); ?>]"
669 <?php
} // end of prior detail line ?>
671 <td
class="last_detail"><?php
echo text($dispcode);
672 $dispcode = "" ?
></td
>
673 <td
class="last_detail"> 
;</td
>
674 <td
class="last_detail">
675 <input name
="form_line[<?php echo attr($code); ?>][bal]" type
="hidden"
676 value
="<?php echo attr(bucks($cdata['bal'])); ?>">
677 <input name
="form_line[<?php echo attr($code); ?>][ins]" type
="hidden"
678 value
="<?php echo attr($cdata['ins']); ?>">
679 <input name
="form_line[<?php echo attr($code); ?>][code_type]" type
="hidden"
680 value
="<?php echo attr($cdata['code_type']); ?>"> <?php
echo text(sprintf("%.2f", $cdata['bal'])); ?
>
683 <td
class="last_detail"></td
>
684 <td
class="last_detail"></td
>
685 <td
class="last_detail">
686 <input name
="form_line[<?php echo attr($code); ?>][pay]"
687 onkeyup
="updateFields(document.forms[0]['form_line[<?php echo attr(addslashes($code)); ?>][pay]'], document.forms[0]['form_line[<?php echo attr(addslashes($code)); ?>][adj]'], document.forms[0]['form_line[<?php echo attr(addslashes($code)); ?>][bal]'], document.forms[0]['form_line[CO-PAY][bal]'], <?php echo ($firstProcCodeIndex == $encount) ? 1 : 0 ?>)"
688 onclick
="this.select()" autofocus size
="10" type
="text" class="form-control"
690 <td
class="last_detail">
691 <input name
="form_line[<?php echo attr($code); ?>][adj]" size
="10" type
="text"
693 value
='<?php echo attr($totalAdjAmount ? $totalAdjAmount : '0.00'); ?>'
694 onclick
="this.select()">
696 <td
class="last_detail" align
="center"><a href
=""
697 onclick
="return writeoff('<?php echo attr(addslashes($code)); ?>')">WO
</a
>
699 <td
class="last_detail">
700 <select
class="form-control" name
="form_line[<?php echo attr($code); ?>][reason]">
702 // Adjustment reasons are now taken from the list_options table.
703 echo " <option value=''></option>\n";
704 $ores = sqlStatement("SELECT option_id, title, is_default FROM list_options " .
705 "WHERE list_id = 'adjreason' AND activity = 1 ORDER BY seq, title");
706 while ($orow = sqlFetchArray($ores)) {
707 echo " <option value='" . attr($orow['option_id']) . "'";
708 if ($orow['is_default']) {
711 echo ">" . text($orow['title']) . "</option>\n";
716 // TBD: Maybe a comment field would be good here, for appending
720 <?php
if ($ALLOW_DELETE) { ?
>
721 <td
class="last_detail"> 
;</td
>
724 <?php
} // end of code ?>
728 <?php
//can change position of buttons by creating a class 'position-override' and adding rule text-align:center or right as the case may be in individual stylesheets ?>
729 <div
class="form-group clearfix">
730 <div
class="col-sm-12 text-left position-override" id
="search-btn">
731 <div
class="btn-group" role
="group">
732 <button type
='submit' class="btn btn-default btn-save" name
='form_save' id
="btn-save-stay"
733 onclick
="this.value='1';"><?php
echo xlt("Save & Stay"); ?
></button
>
734 <button type
='submit' class="btn btn-default btn-save" name
='form_save' id
="btn-save"
735 onclick
="this.value='2';"><?php
echo xlt("Save & Exit"); ?
></button
>
736 <button type
='submit' class="btn btn-link btn-cancel btn-separate-left" name
='form_cancel'
737 id
="btn-cancel" onclick
='refreshOpener()'><?php
echo xlt("Close"); ?
></button
>
743 </div
><!--End of container div
-->
744 <script language
="JavaScript">
745 var f1
= opener
.document
.forms
[0];
746 var f2
= document
.forms
[0];
747 if (f1
.form_source
) {
749 // These support creation and lookup of ar_session table entries:
750 echo " f2.form_reference.value = f1.form_source.value;\n";
751 echo " f2.form_check_date.value = f1.form_paydate.value;\n";
752 echo " //f2.form_deposit_date.value = f1.form_deposit_date.value;\n";
753 echo " if (f1.form_deposit_date.value != '')\n";
754 echo " f2.form_deposit_date.value = f1.form_deposit_date.value;\n";
756 echo " f2.form_deposit_date.value = getFormattedToday();\n";
757 echo " f2.form_payer_id.value = f1.form_payer_id.value;\n";
758 echo " f2.form_pay_total.value = f1.form_amount.value;\n";
759 echo " f2.form_orig_reference.value = f1.form_source.value;\n";
760 echo " f2.form_orig_check_date.value = f1.form_paydate.value;\n";
761 echo " f2.form_orig_deposit_date.value = f1.form_deposit_date.value;\n";
763 // While I'm thinking about it, some notes about eob sessions.
764 // If they do not have all of the session key fields in the search
765 // page, then show a warning at the top of the invoice page.
766 // Also when they go to save the invoice page and a session key
767 // field has changed, alert them to that and allow a cancel.
769 // Another point... when posting EOBs, the incoming payer ID might
770 // not match the payer ID for the patient's insurance. This is
771 // because the same payer might be entered more than once into the
772 // insurance_companies table. I don't think it matters much.