consolidate attr_url function (#2143)
[openemr.git] / interface / billing / sl_eob_search.php
blob33edd495ccda355626e51ecf02e71964f9e27643
1 <?php
2 /**
3 * This the first of two pages to support posting of EOBs.
4 * The second is sl_eob_invoice.php.
6 * @package OpenEMR
7 * @link http://www.open-emr.org
8 * @author Rod Roark <rod@sunsetsystems.com>
9 * @author Bill Cernansky
10 * @author Tony McCormick
11 * @author Roberto Vasquez <robertogagliotta@gmail.com>
12 * @author Jerry Padgett <sjpadgett@gmail.com>
13 * @author Brady Miller <brady.g.miller@gmail.com>
14 * @copyright Copyright (c) 2005-2010 Rod Roark <rod@sunsetsystems.com>
15 * @copyright Copyright (c) 2018 Brady Miller <brady.g.miller@gmail.com>
16 * @copyright Copyright (c) 2018 Jerry Padgett <sjpadgett@gmail.com>
17 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
20 // Updated by Growlingflea Software. now generates correct service and billing facility on statement.
21 // any questions contact Daniel Pflieger at daniel@growlingflea.com
23 require_once("../globals.php");
24 require_once("$srcdir/patient.inc");
25 require_once("$srcdir/invoice_summary.inc.php");
26 require_once("$srcdir/appointments.inc.php");
27 require_once($GLOBALS['OE_SITE_DIR'] . "/statement.inc.php");
28 require_once("$srcdir/api.inc");
29 require_once("$srcdir/forms.inc");
30 require_once("$srcdir/../controllers/C_Document.class.php");
31 require_once("$srcdir/documents.php");
32 require_once("$srcdir/options.inc.php");
33 require_once("$srcdir/acl.inc");
34 require_once "$srcdir/user.inc";
36 use OpenEMR\Billing\ParseERA;
37 use OpenEMR\Billing\SLEOB;
38 use OpenEMR\Core\Header;
39 use OpenEMR\OeUI\OemrUI;
41 $DEBUG = 0; // set to 0 for production, 1 to test
43 $posting_adj_disable = prevSetting('sl_eob_search.', 'posting_adj_disable', 'posting_adj_disable', '');
45 $alertmsg = '';
46 $where = '';
47 $eraname = '';
48 $eracount = 0;
49 /* Load dependencies only if we need them */
50 if (!empty($GLOBALS['portal_onsite_two_enable'])) {
51 /* Addition of onsite portal patient notify of invoice and reformated invoice - sjpadgett 01/2017 */
52 require_once("../../portal/lib/portal_mail.inc");
53 require_once("../../portal/lib/appsql.class.php");
55 function is_auth_portal($pid = 0)
57 if ($pData = sqlQuery("SELECT * FROM `patient_data` WHERE `pid` = ?", array($pid))) {
58 if ($pData['allow_patient_portal'] != "YES") {
59 return false;
60 } else {
61 $_SESSION['portalUser'] = strtolower($pData['fname']) . $pData['id'];
62 return true;
64 } else {
65 return false;
69 function notify_portal($thispid, array $invoices, $template, $invid)
71 $builddir = $GLOBALS['OE_SITE_DIR'] . '/documents/onsite_portal_documents/templates/' . $thispid;
72 if (!is_dir($builddir)) {
73 mkdir($builddir, 0755, true);
76 if (fixup_invoice($template, $builddir . '/invoice' . $invid . '.tpl') != true) {
77 return false;
80 if (SavePatientAudit($thispid, $invoices) != true) {
81 return false;
82 } // this is all the invoice data for portal auditing
83 $note = xl('You have an invoice due for payment in your Patient Documents. There you may pay, download or print the invoice. Thank you.');
84 if (sendMail($_SESSION['authUser'], $note, xlt('Bill/Collect'), '', '0', $_SESSION['authUser'], $_SESSION['authUser'], $_SESSION['portalUser'], $invoices[0]['patient'], "New", '0') == 1) { // remind admin this was sent
85 sendMail($_SESSION['portalUser'], $note, xlt('Bill/Collect'), '', '0', $_SESSION['authUser'], $_SESSION['authUser'], $_SESSION['portalUser'], $invoices[0]['patient'], "New", '0'); // notify patient
86 } else {
87 return false;
90 return true;
93 function fixup_invoice($template, $ifile)
95 $data = file_get_contents($template);
96 if ($data == "") {
97 return false;
100 if (!file_put_contents($ifile, $data)) {
101 return false;
104 return true;
107 function SavePatientAudit($pid, $invs)
109 $appsql = new ApplicationTable();
110 try {
111 $audit = array();
112 $audit['patient_id'] = $pid;
113 $audit['activity'] = "invoice";
114 $audit['require_audit'] = "0";
115 $audit['pending_action'] = "payment";
116 $audit['action_taken'] = "";
117 $audit['status'] = "waiting transaction";
118 $audit['narrative'] = "Request patient online payment.";
119 $audit['table_action'] = '';
120 $audit['table_args'] = json_encode($invs);
121 $audit['action_user'] = $pid;
122 $audit['action_taken_time'] = "";
123 $audit['checksum'] = "";
124 $edata = $appsql->getPortalAudit($pid, 'payment', 'invoice', "waiting transaction", 0);
125 if ($edata['id'] > 0) {
126 $appsql->portalAudit('update', $edata['id'], $audit);
127 } else {
128 $appsql->portalAudit('insert', '', $audit);
130 } catch (Exception $ex) {
131 return $ex;
134 return true;
138 // This is called back by ParseERA::parse_era() if we are processing X12 835's.
139 function era_callback(&$out)
141 global $where, $eracount, $eraname;
142 // print_r($out); // debugging
143 ++$eracount;
144 // $eraname = $out['isa_control_number'];
145 $eraname = $out['gs_date'] . '_' . ltrim($out['isa_control_number'], '0') .
146 '_' . ltrim($out['payer_id'], '0');
147 list($pid, $encounter, $invnumber) = SLEOB::slInvoiceNumber($out);
149 if ($pid && $encounter) {
150 if ($where) {
151 $where .= ' OR ';
154 $where .= "( f.pid = '" . add_escape_custom($pid) . "' AND f.encounter = '" . add_escape_custom($encounter) . "' )";
158 function bucks($amount)
160 if ($amount) {
161 return oeFormatMoney($amount);
165 function validEmail($email)
167 if (preg_match("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$^", $email)) {
168 return true;
171 return false;
174 function emailLogin($patient_id, $message)
176 $patientData = sqlQuery("SELECT * FROM `patient_data` WHERE `pid`=?", array($patient_id));
177 if ($patientData['hipaa_allowemail'] != "YES" || empty($patientData['email']) || empty($GLOBALS['patient_reminder_sender_email'])) {
178 return false;
181 if (!(validEmail($patientData['email']))) {
182 return false;
185 if (!(validEmail($GLOBALS['patient_reminder_sender_email']))) {
186 return false;
189 if ($_SESSION['pc_facility']) {
190 $sql = "select * from facility where id=?";
191 $facility = sqlQuery($sql, array($_SESSION['pc_facility']));
192 } else {
193 $sql = "SELECT * FROM facility ORDER BY billing_location DESC LIMIT 1";
194 $facility = sqlQuery($sql);
197 $mail = new MyMailer();
198 $pt_name = $patientData['fname'] . ' ' . $patientData['lname'];
199 $pt_email = $patientData['email'];
200 $email_subject = ($facility['name'] . ' ' . xl('Patient Statement Bill'));
201 $email_sender = $GLOBALS['patient_reminder_sender_email'];
202 $mail->AddReplyTo($email_sender, $email_sender);
203 $mail->SetFrom($email_sender, $email_sender);
204 $mail->AddAddress($pt_email, $pt_name);
205 $mail->Subject = $email_subject;
206 $mail->MsgHTML("<html><body><div class='wrapper'>" . $message . "</div></body></html>");
207 $mail->IsHTML(true);
208 $mail->AltBody = $message;
210 if ($mail->Send()) {
211 return true;
212 } else {
213 $email_status = $mail->ErrorInfo;
214 error_log("EMAIL ERROR: " . $email_status, 0);
215 return false;
219 // Upload a file to the client's browser
221 function upload_file_to_client($file_to_send)
223 header("Pragma: public");
224 header("Expires: 0");
225 header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
226 header("Content-Type: application/force-download");
227 header("Content-Length: " . filesize($file_to_send));
228 header("Content-Disposition: attachment; filename=" . basename($file_to_send));
229 header("Content-Description: File Transfer");
230 readfile($file_to_send);
231 // flush the content to the browser. If you don't do this, the text from the subsequent
232 // output from this script will be in the file instead of sent to the browser.
233 flush();
234 exit(); //added to exit from process properly in order to stop bad html code -ehrlive
235 // sleep one second to ensure there's no follow-on.
236 sleep(1);
239 function upload_file_to_client_email($ppid, $file_to_send)
241 $message = "";
242 global $STMT_TEMP_FILE_PDF;
243 $file = fopen($file_to_send, "r");//this file contains the text to be converted to pdf.
244 while (!feof($file)) {
245 $OneLine = fgets($file);//one line is read
247 $message = $message . $OneLine . '<br>';
249 $countline++;
252 emailLogin($ppid, $message);
255 function upload_file_to_client_pdf($file_to_send, $aPatFirstName = '', $aPatID = null, $flagCFN = false)
257 //modified for statement title name
258 //Function reads a HTML file and converts to pdf.
260 $aPatFName = convert_safe_file_dir_name($aPatFirstName); //modified for statement title name
261 if ($flagCFN) {
262 $STMT_TEMP_FILE_PDF = $GLOBALS['temporary_files_dir'] . "/Stmt_{$aPatFName}_{$aPatID}.pdf";
263 } else {
264 global $STMT_TEMP_FILE_PDF;
267 global $srcdir;
269 if ($GLOBALS['statement_appearance'] == '1') {
270 require_once("$srcdir/html2pdf/vendor/autoload.php");
271 $pdf2 = new HTML2PDF(
272 $GLOBALS['pdf_layout'],
273 $GLOBALS['pdf_size'],
274 $GLOBALS['pdf_language'],
275 true, // default unicode setting is true
276 'UTF-8', // default encoding setting is UTF-8
277 array($GLOBALS['pdf_left_margin'], $GLOBALS['pdf_top_margin'], $GLOBALS['pdf_right_margin'], $GLOBALS['pdf_bottom_margin']),
278 $_SESSION['language_direction'] == 'rtl' ? true : false
280 ob_start();
281 readfile($file_to_send, "r");//this file contains the HTML to be converted to pdf.
282 //echo $file;
283 $content = ob_get_clean();
285 // Fix a nasty html2pdf bug - it ignores document root!
286 global $web_root, $webserver_root;
287 $i = 0;
288 $wrlen = strlen($web_root);
289 $wsrlen = strlen($webserver_root);
290 while (true) {
291 $i = stripos($content, " src='/", $i + 1);
292 if ($i === false) {
293 break;
296 if (substr($content, $i + 6, $wrlen) === $web_root &&
297 substr($content, $i + 6, $wsrlen) !== $webserver_root) {
298 $content = substr($content, 0, $i + 6) . $webserver_root . substr($content, $i + 6 + $wrlen);
302 $pdf2->WriteHTML($content);
303 $temp_filename = $STMT_TEMP_FILE_PDF;
304 $content_pdf = $pdf2->Output($STMT_TEMP_FILE_PDF, 'F');
305 } else {
306 $pdf = new Cezpdf('LETTER');//pdf creation starts
307 $pdf->ezSetMargins(45, 9, 36, 10);
308 $pdf->selectFont('Courier');
309 $pdf->ezSetY($pdf->ez['pageHeight'] - $pdf->ez['topMargin']);
310 $countline = 1;
311 $file = fopen($file_to_send, "r");//this file contains the text to be converted to pdf.
312 while (!feof($file)) {
313 $OneLine = fgets($file);//one line is read
314 if (stristr($OneLine, "\014") == true && !feof($file)) {//form feed means we should start a new page.
315 $pdf->ezNewPage();
316 $pdf->ezSetY($pdf->ez['pageHeight'] - $pdf->ez['topMargin']);
317 str_replace("\014", "", $OneLine);
320 if (stristr($OneLine, 'REMIT TO') == true || stristr($OneLine, 'Visit Date') == true || stristr($OneLine, 'Future Appointments') == true || stristr($OneLine, 'Current') == true) { //lines are made bold when 'REMIT TO' or 'Visit Date' is there.
321 $pdf->ezText('<b>' . $OneLine . '</b>', 12, array('justification' => 'left', 'leading' => 6));
322 } else {
323 $pdf->ezText($OneLine, 12, array('justification' => 'left', 'leading' => 6));
326 $countline++;
329 $fh = @fopen($STMT_TEMP_FILE_PDF, 'w');//stored to a pdf file
330 if ($fh) {
331 fwrite($fh, $pdf->ezOutput());
332 fclose($fh);
336 header("Pragma: public");//this section outputs the pdf file to browser
337 header("Expires: 0");
338 header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
339 header("Content-Type: application/force-download");
340 header("Content-Length: " . filesize($STMT_TEMP_FILE_PDF));
341 header("Content-Disposition: attachment; filename=" . basename($STMT_TEMP_FILE_PDF));
342 header("Content-Description: File Transfer");
343 readfile($STMT_TEMP_FILE_PDF);
344 // flush the content to the browser. If you don't do this, the text from the subsequent
345 // output from this script will be in the file instead of sent to the browser.
346 flush();
347 exit(); //added to exit from process properly in order to stop bad html code -ehrlive
348 // sleep one second to ensure there's no follow-on.
349 sleep(1);
353 $today = date("Y-m-d");
354 // Print or download statements if requested.
356 if (($_REQUEST['form_print'] || $_REQUEST['form_download'] || $_REQUEST['form_email'] || $_REQUEST['form_pdf']) || $_REQUEST['form_portalnotify'] && $_REQUEST['form_cb']) {
357 if (!verifyCsrfToken($_REQUEST["csrf_token_form"])) {
358 csrfNotVerified();
361 $fhprint = fopen($STMT_TEMP_FILE, 'w');
363 $sqlBindArray = array();
364 $where = "";
365 foreach ($_REQUEST['form_cb'] as $key => $value) {
366 $where .= " OR f.id = ?";
367 array_push($sqlBindArray, $key);
370 if (!empty($where)) {
371 $where = substr($where, 4);
372 $where = '( ' . $where . ' ) AND';
375 $res = sqlStatement("SELECT " .
376 "f.id, f.date, f.pid, f.encounter, f.stmt_count, f.last_stmt_date, f.last_level_closed, f.last_level_billed, f.billing_note as enc_billing_note, " .
377 "p.fname, p.mname, p.lname, p.street, p.city, p.state, p.postal_code, p.billing_note as pat_billing_note, f.provider_id " .
378 "FROM form_encounter AS f, patient_data AS p " .
379 "WHERE $where " .
380 "p.pid = f.pid " .
381 "ORDER BY p.lname, p.fname, f.pid, f.date, f.encounter", $sqlBindArray);
383 $stmt = array();
384 $stmt_count = 0;
386 $flagT = true;
387 $aPatientFirstName = '';
388 $aPatientID = null;
389 $multiplePatients = false;
390 $usePatientNamePdf = false;
392 // get pids for delimits
393 // need to only use summary invoice for multi visits
394 $inv_pid = array();
395 $inv_count = -1;
396 if ($_REQUEST['form_portalnotify']) {
397 foreach ($_REQUEST['form_invpids'] as $key => $v) {
398 if ($_REQUEST['form_cb'][$key]) {
399 array_push($inv_pid, key($v));
403 $rcnt = 0;
404 while ($row = sqlFetchArray($res)) {
405 $rows[] = $row;
406 if (!$inv_pid[$rcnt]) {
407 array_push($inv_pid, $row['pid']);
409 $rcnt++;
411 // This loops once for each invoice/encounter.
413 $rcnt = 0;
414 while ($row = $rows[$rcnt++]) {
415 $svcdate = substr($row['date'], 0, 10);
416 $duedate = $svcdate; // TBD?
417 $duncount = $row['stmt_count'];
418 $enc_note = $row['enc_billing_note'];
420 if ($flagT) {
421 $flagT = false;
422 $aPatientFirstName = $row['fname'];
423 $aPatientID = $row['pid'];
424 $usePatientNamePdf = true;
425 } elseif (!$multiplePatients) {
426 if ($aPatientID != $row['pid']) {
427 $multiplePatients = true;
428 $aPatientFirstName = '';
429 $aPatientID = null;
430 $usePatientNamePdf = false;
434 // If this is a new patient then print the pending statement
435 // and start a new one. This is an associative array:
437 // cid = same as pid
438 // pid = OpenEMR patient ID
439 // patient = patient name
440 // amount = total amount due
441 // adjust = adjustments (already applied to amount)
442 // duedate = due date of the oldest included invoice
443 // age = number of days from duedate to today
444 // to = array of addressee name/address lines
445 // lines = array of:
446 // dos = date of service "yyyy-mm-dd"
447 // desc = description
448 // amount = charge less adjustments
449 // paid = amount paid
450 // notice = 1 for first notice, 2 for second, etc.
451 // detail = array of details, see invoice_summary.inc.php
453 if ($stmt['cid'] != $row['pid']) {
454 if (!empty($stmt)) {
455 ++$stmt_count;
457 $stmt['fid'] = $row['id'];
458 $stmt['cid'] = $row['pid'];
459 $stmt['pid'] = $row['pid'];
460 $stmt['dun_count'] = $row['stmt_count'];
461 $stmt['bill_note'] = $row['pat_billing_note'];
462 $stmt['enc_bill_note'] = $row['enc_billing_note'];
463 $stmt['bill_level'] = $row['last_level_billed'];
464 $stmt['level_closed'] = $row['last_level_closed'];
465 $stmt['patient'] = $row['fname'] . ' ' . $row['lname'];
466 $stmt['encounter'] = $row['encounter'];
467 $stmt['provider_id'] = $row['provider_id'];
468 #If you use the field in demographics layout called
469 #guardiansname this will allow you to send statements to the parent
470 #of a child or a guardian etc
471 if (strlen($row['guardiansname']) == 0) {
472 $stmt['to'] = array($row['fname'] . ' ' . $row['lname']);
473 } else {
474 $stmt['to'] = array($row['guardiansname']);
477 if ($row['street']) {
478 $stmt['to'][] = $row['street'];
481 $stmt['to'][] = $row['city'] . ", " . $row['state'] . " " . $row['postal_code'];
482 $stmt['lines'] = array();
483 $stmt['amount'] = '0.00';
484 $stmt['ins_paid'] = 0;
485 $stmt['today'] = $today;
486 $stmt['duedate'] = $duedate;
487 } else {
488 // Report the oldest due date.
489 if ($duedate < $stmt['duedate']) {
490 $stmt['duedate'] = $duedate;
494 // Recompute age at each invoice.
495 $stmt['age'] = round((strtotime($today) - strtotime($stmt['duedate'])) / (24 * 60 * 60));
497 $invlines = ar_get_invoice_summary($row['pid'], $row['encounter'], true);
498 foreach ($invlines as $key => $value) {
499 $line = array();
500 $line['dos'] = $svcdate;
501 if ($GLOBALS['use_custom_statement']) {
502 $line['desc'] = ($key == 'CO-PAY') ? "Patient Payment" : $value['code_text'];
503 } else {
504 $line['desc'] = ($key == 'CO-PAY') ? "Patient Payment" : "Procedure $key";
507 $line['amount'] = sprintf("%.2f", $value['chg']);
508 $line['adjust'] = sprintf("%.2f", $value['adj']);
509 $line['paid'] = sprintf("%.2f", $value['chg'] - $value['bal']);
510 $line['notice'] = $duncount + 1;
511 $line['detail'] = $value['dtl'];
512 $stmt['lines'][] = $line;
513 $stmt['amount'] = sprintf("%.2f", $stmt['amount'] + $value['bal']);
514 $stmt['ins_paid'] = $stmt['ins_paid'] + $value['ins'];
517 // Record that this statement was run.
518 if (!$DEBUG && !$_REQUEST['form_without']) {
519 sqlStatement("UPDATE form_encounter SET " .
520 "last_stmt_date = ?, stmt_count = stmt_count + 1 " .
521 "WHERE id = ?", array($today, $row['id']));
523 $inv_count += 1;
524 if ($_REQUEST['form_portalnotify']) {
525 if (!is_auth_portal($stmt['pid'])) {
526 $alertmsg = xlt('Notification FAILED: Not Portal Authorized');
527 break;
529 $pvoice[] = $stmt;
530 // we don't want to send the portal multiple invoices, thus this. Last invoice for pid is summary.
531 if ($inv_pid[$inv_count] != $inv_pid[$inv_count + 1]) {
532 fwrite($fhprint, make_statement($stmt));
533 if (!notify_portal($stmt['pid'], $pvoice, $STMT_TEMP_FILE, $stmt['pid'] . "-" . $stmt['encounter'])) {
534 $alertmsg = xlt('Notification FAILED');
535 break;
538 $pvoice = array();
539 flush();
540 ftruncate($fhprint, 0);
541 } else {
542 continue;
544 } else {
545 if ($inv_pid[$inv_count] != $inv_pid[$inv_count + 1]) {
546 $tmp = make_statement($stmt);
547 if (empty($tmp)) {
548 $tmp = xlt("This EOB item does not meet minimum print requirements setup in Globals or there is an unknown error.") . " " . xlt("EOB Id") . ":" . text($inv_pid[$inv_count]) . " " . xlt("Encounter") . ":" . text($stmt[encounter]) . "\n";
549 $tmp .= "<br />\n\014<br /><br />";
551 fwrite($fhprint, $tmp);
554 } // end while
556 if (!empty($stmt)) {
557 ++$stmt_count;
560 fclose($fhprint);
561 sleep(1);
562 // Download or print the file, as selected
563 if ($_REQUEST['form_download']) {
564 upload_file_to_client($STMT_TEMP_FILE);
565 } elseif ($_REQUEST['form_pdf']) {
566 upload_file_to_client_pdf($STMT_TEMP_FILE, $aPatientFirstName, $aPatientID, $usePatientNamePdf);
567 } elseif ($_REQUEST['form_email']) {
568 upload_file_to_client_email($stmt['pid'], $STMT_TEMP_FILE);
569 } elseif ($_REQUEST['form_portalnotify']) {
570 if ($alertmsg == "") {
571 $alertmsg = xl('Sending Invoice to Patient Portal Completed');
573 } else { // Must be print!
574 if ($DEBUG) {
575 $alertmsg = xl("Printing skipped; see test output in") . ' ' . $STMT_TEMP_FILE;
576 } else {
577 exec(escapeshellcmd($STMT_PRINT_CMD) . " " . escapeshellarg($STMT_TEMP_FILE));
578 if ($_REQUEST['form_without']) {
579 $alertmsg = xl('Now printing') . ' ' . $stmt_count . ' ' . xl('statements; invoices will not be updated.');
580 } else {
581 $alertmsg = xl('Now printing') . ' ' . $stmt_count . ' ' . xl('statements and updating invoices.');
583 } // end not debug
584 } // end not form_download
585 } // end statements requested
587 <html>
588 <head>
589 <?php Header::setupHeader(['datetime-picker']); ?>
590 <title><?php echo xlt('EOB Posting - Search'); ?></title>
591 <script language="JavaScript">
592 var mypcc = '1';
594 function checkAll(checked) {
595 var f = document.forms[0];
596 for (var i = 0; i < f.elements.length; ++i) {
597 var ename = f.elements[i].name;
598 if (ename.indexOf('form_cb[') == 0)
599 f.elements[i].checked = checked;
603 function persistCriteria(el, e) {
604 e.preventDefault();
605 let target = "sl_eob_search.posting_adj_disable";
606 let val = el.checked ? 'checked' : '';
607 $.post("./../../library/ajax/user_settings.php",
609 target: target,
610 setting: val,
611 csrf_token_form: "<?php echo attr(collectCsrfToken()); ?>"
616 function npopup(pid) {
617 window.open('sl_eob_patient_note.php?patient_id=' + pid, '_blank', 'width=500,height=250,resizable=1');
618 return false;
621 function toEncSummary(pid) {
622 // Tabs only
623 top.restoreSession();
624 let encurl = 'patient_file/history/encounters.php?billing=1&issue=0&pagesize=20&pagestart=0';
625 let paturl = "patient_file/summary/demographics.php?set_pid=" + pid;
626 parent.left_nav.loadFrame('pat2', 'pat', paturl);
627 // need a little time so can force a billing view
628 setTimeout(function(){parent.left_nav.loadFrame('enc2', 'enc', encurl);}, 3000);
631 $(document).ready(function () {
632 $('.datepicker').datetimepicker({
633 <?php $datetimepicker_timepicker = false; ?>
634 <?php $datetimepicker_showseconds = false; ?>
635 <?php $datetimepicker_formatInput = false; ?>
636 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
637 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
641 </script>
642 <style>
643 @media only screen and (max-width: 768px) {
644 [class*="col-"] {
645 width: 100%;
646 text-align: left !Important;
650 @media only screen and (max-width: 1004px) and (min-width: 641px) {
651 .oe-large {
652 display: none;
655 .oe-small {
656 display: inline-block;
660 @media print {
661 body * {
662 visibility: hidden;
665 .modal-body, .modal-body * {
666 visibility: visible;
669 .modal-body {
670 position: absolute;
671 left: 0;
672 top: 0;
673 width: 100%;
674 height: 10000px;
677 </style>
678 <?php
679 $arrOeUiSettings = array(
680 'heading_title' => xl('EOB Posting - Search'),
681 'include_patient_name' => false,
682 'expandable' => true,
683 'expandable_files' => array('sl_eob_search_xpd'),//all file names need suffix _xpd
684 'action' => "reset",
685 'action_title' => "",
686 'action_href' => "sl_eob_search.php",//only for actions - reset, link or back
687 'show_help_icon' => true,
688 'help_file_name' => "sl_eob_help.php"
690 $oemr_ui = new OemrUI($arrOeUiSettings);
693 </head>
695 <body>
696 <div id="container_div" class="<?php echo $oemr_ui->oeContainer();?>">
697 <div class="row">
698 <div class="col-sm-12">
699 <div class="page-header">
700 <?php echo $oemr_ui->pageHeading() . "\r\n"; ?>
701 </div>
702 </div>
703 </div>
704 <div class="row">
705 <div class="col-sm-12">
706 <form id="formSearch" action="" enctype='multipart/form-data' method='post'>
707 <input type="hidden" name="csrf_token_form" value="<?php echo attr(collectCsrfToken()); ?>"/>
708 <fieldset id="payment-allocate" class="oe-show-hide">
709 <legend>
710 &nbsp;<?php echo xlt('Post Item'); ?><i id="payment-info-do-not-remove"> </i>
711 </legend>
712 <div class="col-xs-12 oe-custom-line">
713 <div class="col-xs-3">
714 <label class="control-label" for="form_payer_id"> <?php echo xlt('Payer'); ?>:</label>
715 <?php
716 $insurancei = getInsuranceProviders();
717 echo " <select name='form_payer_id'id='form_payer_id' class='form-control'>\n";
718 echo " <option value='0'>-- " . xlt('Patient') . " --</option>\n";
719 foreach ($insurancei as $iid => $iname) {
720 echo "<option value='" . attr($iid) . "'";
721 if ($iid == $_REQUEST['form_payer_id']) {
722 echo " selected";
724 echo ">" . text($iname) . "</option>\n";
726 echo " </select>\n";
728 </div>
729 <div class="col-xs-2">
730 <label class="control-label" for="form_source"><?php echo xlt('Source'); ?>:</label>
731 <input type='text' name='form_source' id='form_source' class='form-control'
732 value='<?php echo attr($_REQUEST['form_source']); ?>'
733 title='<?php echo xla("A check number or claim number to identify the payment"); ?>'>
734 </div>
735 <div class="col-xs-2">
736 <label class="control-label" for="form_paydate"><?php echo xlt('Pay Date'); ?>:</label>
737 <input type='text' name='form_paydate' id='form_paydate' class='form-control datepicker'
738 value='<?php echo attr($_REQUEST['form_paydate']); ?>'
739 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)'
740 title='<?php echo xla("Date of payment yyyy-mm-dd"); ?>'>
741 </div>
742 <div class="col-xs-2">
743 <label class="control-label oe-large"
744 for="form_deposit_date"><?php echo xlt('Deposit Date'); ?>:</label>
745 <label class="control-label oe-small" for="form_deposit_date"><?php echo xlt('Dep Date'); ?>
746 :</label>
747 <input type='text' name='form_deposit_date' id='form_deposit_date'
748 class='form-control datepicker'
749 value='<?php echo attr($_REQUEST['form_deposit_date']); ?>'
750 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)'
751 title='<?php echo xla("Date of bank deposit yyyy-mm-dd"); ?>'>
752 </div>
753 <div class="col-xs-2">
754 <label class="control-label" for="form_amount"><?php echo xlt('Amount'); ?>:</label>
755 <input type='text' name='form_amount' id='form_amount' class='form-control'
756 value='<?php echo attr($_REQUEST['form_amount']); ?>'
757 title='<?php echo xla("Paid amount that you will allocate"); ?>'>
758 </div>
759 <div class="col-xs-1">
760 <label class="control-label oe-large" for="only_with_debt"><?php echo xlt('Pt Debt'); ?>:</label>
762 <label class="control-label oe-small" for="only_with_debt"><?php echo xlt('Debt'); ?>:</label>
764 <div class="text-center">
765 <input <?php echo $_REQUEST['only_with_debt'] ? 'checked=checked' : ''; ?>
766 type="checkbox" name="only_with_debt" id="only_with_debt"/>
767 </div>
768 </div>
769 </div>
770 </fieldset>
771 <fieldset id="search-upload">
772 <legend>
773 &nbsp;<span><?php echo xlt('Select Method'); ?></span>&nbsp;<i id='select-method-tooltip'
774 class="fa fa-info-circle oe-superscript"
775 aria-hidden="true"></i>
776 <div id="radio-div" class="pull-right oe-legend-radio">
777 <label class="radio-inline">
778 <input type="radio" id="invoice_search" name="radio-search" onclick=""
779 value="inv-search"><?php echo xlt('Invoice Search'); ?>
780 </label>
781 <label class="radio-inline">
782 <input type="radio" id="era_upload" name="radio-search" onclick=""
783 value="era-upld"><?php echo xlt('ERA Upload'); ?>
784 </label>
785 </div>
787 <input type="hidden" id="hid1" value="<?php echo xla('Invoice Search'); ?>">
788 <input type="hidden" id="hid2" value="<?php echo xla('ERA Upload'); ?>">
789 <input type="hidden" id="hid3" value="<?php echo xla('Select Method'); ?>">
790 </legend>
791 <div class="col-xs-12 .oe-custom-line oe-show-hide" id='inv-search'>
792 <div class="col-xs-3">
793 <label class="control-label" for="form_name"><?php echo xlt('Name'); ?>:</label>
794 <input type='text' name='form_name' id='form_name' class='form-control'
795 value='<?php echo attr($_REQUEST['form_name']); ?>'
796 title='<?php echo xla("Any part of the patient name, or \"last,first\", or \"X-Y\""); ?>'
797 placeholder='<?php echo xla('Last name, First name'); ?>'>
798 </div>
799 <div class="col-xs-2">
800 <label class="control-label" for="form_pid"><?php echo xlt('Chart ID'); ?>:</label>
801 <input type='text' name='form_pid' id='form_pid' class='form-control'
802 value='<?php echo attr($_REQUEST['form_pid']); ?>'
803 title='<?php echo xla("Patient chart ID"); ?>'>
804 </div>
805 <div class="col-xs-2">
806 <label class="control-label" for="form_encounter"><?php echo xlt('Encounter'); ?>:</label>
807 <input type='text' name='form_encounter' id='form_encounter' class='form-control'
808 value='<?php echo attr($_REQUEST['form_encounter']); ?>'
809 title='<?php echo xla("Encounter number"); ?>'>
810 </div>
811 <div class="col-xs-2">
812 <label class="control-label oe-large"
813 for="form_date"><?php echo xlt('Service Date From'); ?>:</label>
814 <label class="control-label oe-small" for="form_date"><?php echo xlt('Svc Date'); ?>
815 :</label>
816 <input type='text' name='form_date' id='form_date' class='form-control datepicker'
817 value='<?php echo attr($_REQUEST['form_date']); ?>'
818 title='<?php echo xla("Date of service mm/dd/yyyy"); ?>'>
819 </div>
820 <div class="col-xs-2">
821 <label class="control-label" for="form_to_date"><?php echo xlt('Service Date To'); ?>
822 :</label>
823 <input type='text' name='form_to_date' id='form_to_date' class='form-control datepicker'
824 value='<?php echo attr($_REQUEST['form_to_date']); ?>'
825 title='<?php echo xla("Ending DOS mm/dd/yyyy if you wish to enter a range"); ?>'>
826 </div>
827 <div class="col-xs-1" style="padding-right:0px">
828 <label class="control-label" for="type_name"><?php echo xlt('Type'); ?>:</label>
829 <select name='form_category' id='form_category' class='form-control'>
830 <?php
831 foreach (array(xl('Open'), xl('All'), xl('Due Pt'), xl('Due Ins')) as $value) {
832 echo " <option value='" . attr($value) . "'";
833 if ($_REQUEST['form_category'] == $value) {
834 echo " selected";
836 echo ">" . text($value) . "</option>\n";
839 </select>
840 </div>
841 </div>
842 <div class="col-xs-12 .oe-custom-line oe-show-hide" id='era-upld'>
843 <div class="form-group col-xs9 oe-file-div">
844 <div class="input-group">
845 <label class="input-group-btn">
846 <span class="btn btn-default">Browse&hellip;<input type="file" id="uploadedfile" name="form_erafile" style="display: none;">
847 <input name="MAX_FILE_SIZE" type="hidden" value="5000000">
848 </span>
849 </label>
850 <input type="text" class="form-control"
851 placeholder="<?php echo xla('Click Browse and select one Electronic Remittance Advice (ERA) file...'); ?>"
852 readonly>
853 </div>
854 </div>
855 </div>
856 </fieldset>
857 <?php //can change position of buttons by creating a class 'position-override' and adding rule text-alig:center or right as the case may be in individual stylesheets ?>
858 <div class="form-group clearfix">
859 <div class="col-sm-12 position-override oe-show-hide" id="search-btn">
860 <div class="btn-group" role="group">
861 <button type='submit' class="btn btn-default btn-search oe-show-hide" name='form_search'
862 id="btn-inv-search"
863 value='<?php echo xla("Search"); ?>'><?php echo xlt("Search"); ?></button>
864 <button type='submit' class="btn btn-default btn-save oe-show-hide" name='form_search'
865 id="btn-era-upld"
866 value='<?php echo xla("Upload"); ?>'><?php echo xlt("Upload"); ?></button>
867 </div>
868 </div>
869 </div>
870 <fieldset id="search-results" class="oe-show-hide">
871 <legend><span><?php echo xlt('Search Results'); ?></span>
872 <div class="pull-right oe-legend-radio">
873 <label class="checkbox-inline">
874 <input type="checkbox" id="posting_adj_disable" name="posting_adj_disable"
875 onchange='persistCriteria(this, event)'
876 title="<?php echo xlt("Disable automatically calculating balance adjustments for invoice posting") ?>"
877 value="<?php echo attr($posting_adj_disable); ?>"
878 <?php echo ' ' . attr($posting_adj_disable); ?> /><?php echo xlt('Disable Auto Adjustments'); ?>
879 </label>
880 </div>
881 </legend>
882 <div class="table-responsive">
883 <?php
884 if ($_REQUEST['form_search'] || $_REQUEST['form_print']) {
885 if (!verifyCsrfToken($_REQUEST["csrf_token_form"])) {
886 csrfNotVerified();
889 $form_name = trim($_REQUEST['form_name']);
890 $form_pid = trim($_REQUEST['form_pid']);
891 $form_encounter = trim($_REQUEST['form_encounter']);
892 $form_date = fixDate($_REQUEST['form_date'], "");
893 $form_to_date = fixDate($_REQUEST['form_to_date'], "");
895 $where = "";
897 // Handle X12 835 file upload.
899 if ($_FILES['form_erafile']['size']) {
900 $tmp_name = $_FILES['form_erafile']['tmp_name'];
902 // Handle .zip extension if present. Probably won't work on Windows.
903 if (strtolower(substr($_FILES['form_erafile']['name'], -4)) == '.zip') {
904 rename($tmp_name, "$tmp_name.zip");
905 exec("unzip -p " . escapeshellarg($tmp_name . ".zip") . " > " . escapeshellarg($tmp_name));
906 unlink("$tmp_name.zip");
909 echo "<!-- Notes from ERA upload processing:\n";
910 $alertmsg .= ParseERA::parse_era($tmp_name, 'era_callback');
911 echo "-->\n";
912 $erafullname = $GLOBALS['OE_SITE_DIR'] . "/era/$eraname.edi";
914 if (is_file($erafullname)) {
915 $alertmsg .= "Warning: Set $eraname was already uploaded ";
916 if (is_file($GLOBALS['OE_SITE_DIR'] . "/era/$eraname.html")) {
917 $alertmsg .= "and processed. ";
918 } else {
919 $alertmsg .= "but not yet processed. ";
922 rename($tmp_name, $erafullname);
923 } // End 835 upload
925 if ($eracount) {
926 // Note that ParseERA::parse_era() modified $eracount and $where.
927 if (!$where) {
928 $where = '1 = 2';
930 } else {
931 if ($form_name) {
932 if ($where) {
933 $where .= " AND ";
935 // Allow the last name to be followed by a comma and some part of a first name.
936 if (preg_match('/^(.*\S)\s*,\s*(.*)/', $form_name, $matches)) {
937 $where .= "p.lname LIKE '" . add_escape_custom($matches[1]) . "%' AND p.fname LIKE '" . add_escape_custom($matches[2]) . "%'";
938 // Allow a filter like "A-C" on the first character of the last name.
939 } elseif (preg_match('/^(\S)\s*-\s*(\S)$/', $form_name, $matches)) {
940 $tmp = '1 = 2';
941 while (ord($matches[1]) <= ord($matches[2])) {
942 $tmp .= " OR p.lname LIKE '" . add_escape_custom($matches[1]) . "%'";
943 $matches[1] = chr(ord($matches[1]) + 1);
945 $where .= "( $tmp ) ";
946 } else {
947 $where .= "p.lname LIKE '%" . add_escape_custom($form_name) . "%'";
950 if ($form_pid) {
951 if ($where) {
952 $where .= " AND ";
954 $where .= "f.pid = '" . add_escape_custom($form_pid) . "'";
956 if ($form_encounter) {
957 if ($where) {
958 $where .= " AND ";
960 $where .= "f.encounter = '" . add_escape_custom($form_encounter) . "'";
962 if ($form_date) {
963 if ($where) {
964 $where .= " AND ";
966 if ($form_to_date) {
967 $where .= "f.date >= '" . add_escape_custom($form_date) . "' AND f.date <= '" . add_escape_custom($form_to_date) . "'";
968 } else {
969 $where .= "f.date = '" . add_escape_custom($form_date) . "'";
972 if (!$where) {
973 if ($_REQUEST['form_category'] == 'All') {
974 $alertmsg .= xlt("At least one search parameter is required if you select All.");
975 } else {
976 $where = "1 = 1";
981 // Notes that as of release 4.1.1 the copays are stored
982 // in the ar_activity table marked with a PCP in the account_code column.
983 $query = "SELECT f.id, f.pid, f.encounter, f.date, " .
984 "f.last_level_billed, f.last_level_closed, f.last_stmt_date, f.stmt_count, " .
985 "p.fname, p.mname, p.lname, p.pubpid, p.billing_note, " .
986 "( SELECT SUM(b.fee) FROM billing AS b WHERE " .
987 "b.pid = f.pid AND b.encounter = f.encounter AND " .
988 "b.activity = 1 AND b.code_type != 'COPAY' ) AS charges, " .
989 "( SELECT SUM(a.pay_amount) FROM ar_activity AS a WHERE " .
990 "a.pid = f.pid AND a.encounter = f.encounter AND a.payer_type = 0 AND a.account_code = 'PCP')*-1 AS copays, " .
991 "( SELECT SUM(a.pay_amount) FROM ar_activity AS a WHERE " .
992 "a.pid = f.pid AND a.encounter = f.encounter AND a.account_code != 'PCP') AS payments, " .
993 "( SELECT SUM(a.adj_amount) FROM ar_activity AS a WHERE " .
994 "a.pid = f.pid AND a.encounter = f.encounter ) AS adjustments " .
995 "FROM form_encounter AS f " .
996 "JOIN patient_data AS p ON p.pid = f.pid " .
997 "WHERE $where " .
998 "ORDER BY p.lname, p.fname, p.mname, f.pid, f.encounter";
1000 // Note that unlike the SQL-Ledger case, this query does not weed
1001 // out encounters that are paid up. Also the use of sub-selects
1002 // will require MySQL 4.1 or greater.
1004 // echo "<!-- $query -->\n"; // debugging
1005 $num_invoices = 0;
1006 if (!$alertmsg) {
1007 $t_res = sqlStatement($query);
1008 $num_invoices = sqlNumRows($t_res);
1011 if ($eracount && $num_invoices != $eracount) {
1012 $alertmsg .= "Of $eracount remittances, there are $num_invoices " .
1013 "matching encounters in OpenEMR. ";
1016 <table class="table table-striped table-condensed">
1017 <thead>
1018 <tr>
1019 <th class="id dehead"><?php echo xlt('id'); ?></th>
1020 <th class="dehead">&nbsp;<?php echo xlt('Patient'); ?></th>
1021 <th class="dehead">&nbsp;<?php echo xlt('Invoice'); ?></th>
1022 <th class="dehead">&nbsp;<?php echo xlt('Svc Date'); ?></th>
1023 <th class="dehead">&nbsp;<?php echo xlt('Last Stmt'); ?></th>
1024 <th align="right" class="dehead"><?php echo xlt('Charge'); ?>&nbsp;</th>
1025 <th align="right" class="dehead"><?php echo xlt('Adjust'); ?>&nbsp;</th>
1026 <th align="right" class="dehead"><?php echo xlt('Paid'); ?>&nbsp;</th>
1027 <th align="right" class="dehead"><?php echo xlt('Balance'); ?>&nbsp;</th>
1028 <th align="center" class="dehead"><?php echo xlt('Prv'); ?></th>
1029 <?php
1030 if (!$eracount) { ?>
1031 <th align="left" class="dehead"><?php echo xlt('Sel'); ?></th>
1032 <th align="center" class="dehead"><?php echo xlt('Email'); ?></th>
1033 <?php
1034 } ?>
1035 </tr>
1036 </thead>
1037 <?php
1038 $orow = -1;
1040 while ($row = sqlFetchArray($t_res)) {
1041 $balance = sprintf("%.2f", $row['charges'] + $row['copays'] - $row['payments'] - $row['adjustments']);
1042 //new filter only patients with debt.
1043 if ($_REQUEST['only_with_debt'] && $balance <= 0) {
1044 continue;
1048 if ($_REQUEST['form_category'] != 'All' && $eracount == 0 && $balance == 0) {
1049 continue;
1052 // $duncount was originally supposed to be the number of times that
1053 // the patient was sent a statement for this invoice.
1055 $duncount = $row['stmt_count'];
1057 // But if we have not yet billed the patient, then compute $duncount as a
1058 // negative count of the number of insurance plans for which we have not
1059 // yet closed out insurance.
1061 if (!$duncount) {
1062 for ($i = 1; $i <= 3 && SLEOB::arGetPayerID($row['pid'], $row['date'], $i);
1063 ++$i) {
1065 $duncount = $row['last_level_closed'] + 1 - $i;
1068 $isdueany = ($balance > 0);
1070 // An invoice is now due from the patient if money is owed and we are
1071 // not waiting for insurance to pay.
1073 $isduept = ($duncount >= 0 && $isdueany) ? " checked" : "";
1075 // Skip invoices not in the desired "Due..." category.
1077 if (substr($_REQUEST['form_category'], 0, 3) == 'Due' && !$isdueany) {
1078 continue;
1080 if ($_REQUEST['form_category'] == 'Due Ins' && ($duncount >= 0 || !$isdueany)) {
1081 continue;
1083 if ($_REQUEST['form_category'] == 'Due Pt' && ($duncount < 0 || !$isdueany)) {
1084 continue;
1087 $bgcolor = ((++$orow & 1) ? "#ffdddd" : "#ddddff");
1089 $svcdate = substr($row['date'], 0, 10);
1090 $last_stmt_date = empty($row['last_stmt_date']) ? '' : $row['last_stmt_date'];
1092 // Determine if customer is in collections.
1094 $billnote = $row['billing_note'];
1095 $in_collections = stristr($billnote, 'IN COLLECTIONS') !== false;
1097 <tr>
1098 <td class="detail">
1099 <a href=""
1100 onclick="return npopup(<?php echo attr(addslashes($row['pid'])) ?>)"><?php echo text($row['pid']); ?></a>
1101 </td>
1102 <td class="detail">&nbsp;
1103 <a href=""
1104 onclick="return npopup(<?php echo attr(addslashes($row['pid'])) ?>)"><?php echo text($row['lname']) . ', ' . text($row['fname']); ?></a>
1105 </td>
1106 <td class="detail">&nbsp;
1107 <a href="sl_eob_invoice.php?isPosting=1&id=<?php echo attr_url($row['id']); ?>"
1108 target="_blank"><?php echo text($row['pid']) . '.' . text($row['encounter']); ?></a>
1109 </td>
1110 <td class="detail">&nbsp;<?php echo text(oeFormatShortDate($svcdate)); ?></td>
1111 <td class="detail">
1112 &nbsp;<?php echo text(oeFormatShortDate($last_stmt_date)); ?></td>
1113 <td align="right" class="detail"><?php echo text(bucks($row['charges'])); ?>&nbsp;
1114 </td>
1115 <td align="right" class="detail"><?php echo text(bucks($row['adjustments'])); ?>
1116 &nbsp;
1117 </td>
1118 <td align="right"
1119 class="detail"><?php echo text(bucks($row['payments'] - $row['copays'])); ?>
1120 &nbsp;
1121 </td>
1122 <td align="right" class="detail"><?php echo text(bucks($balance)); ?>&nbsp;</td>
1123 <td align="center"
1124 class="detail"><?php echo $duncount ? text($duncount) : "&nbsp;" ?></td>
1125 <?php if (!$eracount) { ?>
1126 <td class="detail" align="left">
1127 <input type='checkbox'
1128 name='form_cb[<?php echo attr($row['id']) ?>]'<?php echo text($isduept); ?> />
1129 <?php
1130 if ($in_collections) {
1131 echo "<b><font color='red'>IC</font></b>";
1132 } ?>
1133 <?php
1134 if (function_exists('is_auth_portal') ? is_auth_portal($row['pid']) : false) {
1135 echo(' PPt');
1136 echo("<input type='hidden' name='form_invpids[" . attr($row['id']) . "][" . attr($row['pid']) . "]' />");
1137 $is_portal = true;
1138 } ?>
1139 </td>
1140 <?php } ?>
1141 <td align="left" class="detail">
1142 <?php
1143 $patientData = sqlQuery("SELECT * FROM `patient_data` WHERE `pid`=?", array($row['pid']));
1144 if ($patientData['hipaa_allowemail'] == "YES" && $patientData['allow_patient_portal'] == "YES" && $patientData['hipaa_notice'] == "YES" && validEmail($patientData['email'])) {
1145 echo xlt("YES");
1146 } else {
1147 echo xlt("NO");
1150 </td>
1151 </tr>
1152 <?php
1153 } // end while
1154 } // end search/print logic
1156 </table>
1157 </div><!--End of table-responsive div-->
1158 </fieldset>
1159 <?php //can change position of buttons by creating a class 'position-override' and adding rule text-alig:center or right as the case may be in individual stylesheets ?>
1160 <div class="form-group clearfix">
1161 <div class="col-sm-12 text-left position-override oe-show-hide" id="statement-download">
1162 <div class="btn-group" role="group">
1163 <?php
1164 if ($eracount) { ?>
1165 <button type="button" class="btn btn-default btn-save" name="Submit"
1166 onclick='processERA()' value="<?php echo xla('Process ERA File'); ?>">
1167 <?php echo xlt('Process ERA File'); ?></button>
1168 <?php
1169 } else { ?>
1170 <button type="button" class="btn btn-default btn-save" name="Submit1"
1171 onclick='checkAll(true)'><?php echo xlt('Select All'); ?></button>
1172 <button type="button" class="btn btn-default btn-undo" name="Submit2"
1173 onclick='checkAll(false)'><?php echo xlt('Clear All'); ?></button>
1174 <?php if ($GLOBALS['statement_appearance'] != '1') { ?>
1175 <button type="submit" class="btn btn-default btn-print" name='form_print'
1176 value="<?php echo xla('Print Selected Statements'); ?>">
1177 <?php echo xlt('Print Selected Statements'); ?></button>
1178 <button type="submit" class="btn btn-default btn-download" name='form_download'
1179 value="<?php echo xla('Download Selected Statements'); ?>">
1180 <?php echo xlt('Download Selected Statements'); ?></button>
1181 <?php } ?>
1182 <button type="submit" class="btn btn-default btn-download" name='form_pdf'
1183 value="<?php echo xla('PDF Download Selected Statements'); ?>">
1184 <?php echo xlt('PDF Download Selected Statements'); ?></button>
1185 <button type="submit" class="btn btn-default btn-mail" name='form_download'
1186 value="<?php echo xla('Email Selected Statements'); ?>">
1187 <?php echo xlt('Email Selected Statements'); ?></button>
1188 <?php
1189 if ($is_portal) { ?>
1190 <button type="submit" class="btn btn-default btn-save" name='form_portalnotify'
1191 value="<?php echo xla('Notify via Patient Portal'); ?>">
1192 <?php echo xlt('Notify via Patient Portal'); ?></button>
1193 <?php
1197 <input type='checkbox' class="btn-separate-left" name='form_without'
1198 value='1'/><?php echo xlt('Without Update'); ?>
1199 </div>
1200 </div>
1201 </div>
1202 </form>
1203 </div>
1204 </div>
1205 </div> <!--End of Container div-->
1206 <?php $oemr_ui->oeBelowContainerDiv();?>
1208 <script language="JavaScript">
1209 function processERA() {
1210 var f = document.forms[0];
1211 var debug = f.form_without.checked ? '1' : '0';
1212 var paydate = f.form_paydate.value;
1213 window.open('sl_eob_process.php?eraname=' + <?php echo js_url($eraname); ?> + '&debug=' + encodeURIComponent(debug) + '&paydate=' + encodeURIComponent(paydate) + '&original=original' + '&csrf_token_form=' + <?php echo js_url(collectCsrfToken()); ?>, '_blank');
1214 return false;
1217 $(function () {
1218 //https://www.abeautifulsite.net/whipping-file-inputs-into-shape-with-bootstrap-3
1219 // We can attach the `fileselect` event to all file inputs on the page
1220 $(document).on('change', ':file', function () {
1221 var input = $(this),
1222 numFiles = input.get(0).files ? input.get(0).files.length : 1,
1223 label = input.val().replace(/\\/g, '/').replace(/.*\//, '');
1224 input.trigger('fileselect', [numFiles, label]);
1227 // We can watch for our custom `fileselect` event like this
1228 $(document).ready(function () {
1229 $(':file').on('fileselect', function (event, numFiles, label) {
1230 var input = $(this).parents('.input-group').find(':text'),
1231 log = numFiles > 1 ? numFiles + ' files selected' : label;
1233 if (input.length) {
1234 input.val(log);
1236 else {
1237 if (log) alert(log);
1243 //to dynamically show /hide relevant divs and change Fieldset legends
1244 $(document).ready(function () {
1245 $("input[name=radio-search]").on("change", function () {
1247 let flip = $(this).val();
1248 $(".oe-show-hide").hide();
1249 $("#" + flip).show();
1250 if (flip == 'inv-search') {
1251 $("#search-upload").insertAfter("#payment-allocate");
1252 $('#payment-allocate').show();
1253 $('#search-btn').show();
1254 $('#btn-inv-search').show();
1255 var legend_text = $('#hid1').val();
1256 $('#search-upload').find('legend').find('span').text(legend_text);
1257 $('#search-upload').find('#form_name').focus();
1258 $('#select-method-tooltip').hide();
1260 else if (flip == 'era-upld') {
1261 $('#payment-allocate').hide();
1262 $('#search-btn').show();
1263 $('#btn-era-upld').show();
1264 var legend_text = $('#hid2').val();
1265 $('#search-upload').find('legend').find('span').text(legend_text);
1266 $('#select-method-tooltip').hide();
1268 else {
1269 $('#payment-allocate').hide();
1270 $('#search-btn').hide();
1271 var legend_text = $('#hid3').val();
1272 $('#search-upload').find('legend').find('span').text(legend_text);
1273 $('#select-method-tooltip').show();
1277 <?php
1278 if ($alertmsg) {
1279 echo "alert('" . addslashes($alertmsg) . "');\n";
1283 $(document).ready(function () {
1284 //using jquery-ui-1-12-1 tooltip instead of bootstrap tooltip
1285 $('#select-method-tooltip').attr("title", "<?php echo xla('Click on either the Invoice Search button on the far right, for manual entry or ERA Upload button for uploading an entire electronic remittance advice ERA file'); ?>").tooltip();
1287 </script>
1288 <?php
1289 $tr_str = xl('Search');
1290 if ($_REQUEST['form_search'] == "$tr_str") { ?>
1291 <script>
1292 $("#payment-allocate").insertAfter("#search-upload");
1293 $('#payment-allocate').show();
1294 $("#search-results").show();
1295 $("#statement-download").show();
1296 </script>
1297 <?php
1300 <?php
1301 $tr_str = xl('Upload');
1302 if ($_REQUEST['form_search'] == "$tr_str") { ?>
1303 <script>
1304 $('#era-upld').show();
1305 $('#search-results').show();
1306 $("#statement-download").show();
1307 </script>
1308 <?php
1313 </body>
1314 </html>