bug fix march continued (#1921)
[openemr.git] / interface / billing / sl_eob_search.php
blob028e815d0237d0cd03f842df8c1a8e7800dc90cc
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 require_once("../globals.php");
21 require_once("$srcdir/patient.inc");
22 require_once("$srcdir/invoice_summary.inc.php");
23 require_once("$srcdir/appointments.inc.php");
24 require_once($GLOBALS['OE_SITE_DIR'] . "/statement.inc.php");
25 require_once("$srcdir/parse_era.inc.php");
26 require_once("$srcdir/sl_eob.inc.php");
27 require_once("$srcdir/api.inc");
28 require_once("$srcdir/forms.inc");
29 require_once("$srcdir/../controllers/C_Document.class.php");
30 require_once("$srcdir/documents.php");
31 require_once("$srcdir/options.inc.php");
32 require_once("$srcdir/acl.inc");
33 require_once "$srcdir/user.inc";
35 use OpenEMR\Core\Header;
37 $DEBUG = 0; // set to 0 for production, 1 to test
39 $posting_adj_disable = prevSetting('sl_eob_search.', 'posting_adj_disable', 'posting_adj_disable', '');
41 $alertmsg = '';
42 $where = '';
43 $eraname = '';
44 $eracount = 0;
45 /* Load dependencies only if we need them */
46 if (!empty($GLOBALS['portal_onsite_two_enable'])) {
47 /* Addition of onsite portal patient notify of invoice and reformated invoice - sjpadgett 01/2017 */
48 require_once("../../portal/lib/portal_mail.inc");
49 require_once("../../portal/lib/appsql.class.php");
51 function is_auth_portal($pid = 0)
53 if ($pData = sqlQuery("SELECT * FROM `patient_data` WHERE `pid` = ?", array($pid))) {
54 if ($pData['allow_patient_portal'] != "YES") {
55 return false;
56 } else {
57 $_SESSION['portalUser'] = strtolower($pData['fname']) . $pData['id'];
58 return true;
60 } else {
61 return false;
65 function notify_portal($thispid, array $invoices, $template, $invid)
67 $builddir = $GLOBALS['OE_SITE_DIR'] . '/documents/onsite_portal_documents/templates/' . $thispid;
68 if (!is_dir($builddir)) {
69 mkdir($builddir, 0755, true);
72 if (fixup_invoice($template, $builddir . '/invoice' . $invid . '.tpl') != true) {
73 return false;
76 if (SavePatientAudit($thispid, $invoices) != true) {
77 return false;
78 } // this is all the invoice data for portal auditing
79 $note = xl('You have an invoice due for payment in your Patient Documents. There you may pay, download or print the invoice. Thank you.');
80 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
81 sendMail($_SESSION['portalUser'], $note, xlt('Bill/Collect'), '', '0', $_SESSION['authUser'], $_SESSION['authUser'], $_SESSION['portalUser'], $invoices[0]['patient'], "New", '0'); // notify patient
82 } else {
83 return false;
86 return true;
89 function fixup_invoice($template, $ifile)
91 $data = file_get_contents($template);
92 if ($data == "") {
93 return false;
96 if (!file_put_contents($ifile, $data)) {
97 return false;
100 return true;
103 function SavePatientAudit($pid, $invs)
105 $appsql = new ApplicationTable();
106 try {
107 $audit = array();
108 $audit['patient_id'] = $pid;
109 $audit['activity'] = "invoice";
110 $audit['require_audit'] = "0";
111 $audit['pending_action'] = "payment";
112 $audit['action_taken'] = "";
113 $audit['status'] = "waiting transaction";
114 $audit['narrative'] = "Request patient online payment.";
115 $audit['table_action'] = '';
116 $audit['table_args'] = json_encode($invs);
117 $audit['action_user'] = $pid;
118 $audit['action_taken_time'] = "";
119 $audit['checksum'] = "";
120 $edata = $appsql->getPortalAudit($pid, 'payment', 'invoice', "waiting transaction", 0);
121 if ($edata['id'] > 0) {
122 $appsql->portalAudit('update', $edata['id'], $audit);
123 } else {
124 $appsql->portalAudit('insert', '', $audit);
126 } catch (Exception $ex) {
127 return $ex;
130 return true;
134 // This is called back by parse_era() if we are processing X12 835's.
135 function era_callback(&$out)
137 global $where, $eracount, $eraname;
138 // print_r($out); // debugging
139 ++$eracount;
140 // $eraname = $out['isa_control_number'];
141 $eraname = $out['gs_date'] . '_' . ltrim($out['isa_control_number'], '0') .
142 '_' . ltrim($out['payer_id'], '0');
143 list($pid, $encounter, $invnumber) = slInvoiceNumber($out);
145 if ($pid && $encounter) {
146 if ($where) {
147 $where .= ' OR ';
150 $where .= "( f.pid = '" . add_escape_custom($pid) . "' AND f.encounter = '" . add_escape_custom($encounter) . "' )";
154 function bucks($amount)
156 if ($amount) {
157 return oeFormatMoney($amount);
161 function validEmail($email)
163 if (preg_match("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$^", $email)) {
164 return true;
167 return false;
170 function emailLogin($patient_id, $message)
172 $patientData = sqlQuery("SELECT * FROM `patient_data` WHERE `pid`=?", array($patient_id));
173 if ($patientData['hipaa_allowemail'] != "YES" || empty($patientData['email']) || empty($GLOBALS['patient_reminder_sender_email'])) {
174 return false;
177 if (!(validEmail($patientData['email']))) {
178 return false;
181 if (!(validEmail($GLOBALS['patient_reminder_sender_email']))) {
182 return false;
185 if ($_SESSION['pc_facility']) {
186 $sql = "select * from facility where id=?";
187 $facility = sqlQuery($sql, array($_SESSION['pc_facility']));
188 } else {
189 $sql = "SELECT * FROM facility ORDER BY billing_location DESC LIMIT 1";
190 $facility = sqlQuery($sql);
193 $mail = new MyMailer();
194 $pt_name = $patientData['fname'] . ' ' . $patientData['lname'];
195 $pt_email = $patientData['email'];
196 $email_subject = ($facility['name'] . ' ' . xl('Patient Statement Bill'));
197 $email_sender = $GLOBALS['patient_reminder_sender_email'];
198 $mail->AddReplyTo($email_sender, $email_sender);
199 $mail->SetFrom($email_sender, $email_sender);
200 $mail->AddAddress($pt_email, $pt_name);
201 $mail->Subject = $email_subject;
202 $mail->MsgHTML("<html><body><div class='wrapper'>" . $message . "</div></body></html>");
203 $mail->IsHTML(true);
204 $mail->AltBody = $message;
206 if ($mail->Send()) {
207 return true;
208 } else {
209 $email_status = $mail->ErrorInfo;
210 error_log("EMAIL ERROR: " . $email_status, 0);
211 return false;
215 // Upload a file to the client's browser
217 function upload_file_to_client($file_to_send)
219 header("Pragma: public");
220 header("Expires: 0");
221 header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
222 header("Content-Type: application/force-download");
223 header("Content-Length: " . filesize($file_to_send));
224 header("Content-Disposition: attachment; filename=" . basename($file_to_send));
225 header("Content-Description: File Transfer");
226 readfile($file_to_send);
227 // flush the content to the browser. If you don't do this, the text from the subsequent
228 // output from this script will be in the file instead of sent to the browser.
229 flush();
230 exit(); //added to exit from process properly in order to stop bad html code -ehrlive
231 // sleep one second to ensure there's no follow-on.
232 sleep(1);
235 function upload_file_to_client_email($ppid, $file_to_send)
237 $message = "";
238 global $STMT_TEMP_FILE_PDF;
239 $file = fopen($file_to_send, "r");//this file contains the text to be converted to pdf.
240 while (!feof($file)) {
241 $OneLine = fgets($file);//one line is read
243 $message = $message . $OneLine . '<br>';
245 $countline++;
248 emailLogin($ppid, $message);
251 function upload_file_to_client_pdf($file_to_send, $aPatFirstName = '', $aPatID = null, $flagCFN = false)
253 //modified for statement title name
254 //Function reads a HTML file and converts to pdf.
256 $aPatFName = convert_safe_file_dir_name($aPatFirstName); //modified for statement title name
257 if ($flagCFN) {
258 $STMT_TEMP_FILE_PDF = $GLOBALS['temporary_files_dir'] . "/Stmt_{$aPatFName}_{$aPatID}.pdf";
259 } else {
260 global $STMT_TEMP_FILE_PDF;
263 global $srcdir;
265 if ($GLOBALS['statement_appearance'] == '1') {
266 require_once("$srcdir/html2pdf/vendor/autoload.php");
267 $pdf2 = new HTML2PDF(
268 $GLOBALS['pdf_layout'],
269 $GLOBALS['pdf_size'],
270 $GLOBALS['pdf_language'],
271 true, // default unicode setting is true
272 'UTF-8', // default encoding setting is UTF-8
273 array($GLOBALS['pdf_left_margin'], $GLOBALS['pdf_top_margin'], $GLOBALS['pdf_right_margin'], $GLOBALS['pdf_bottom_margin']),
274 $_SESSION['language_direction'] == 'rtl' ? true : false
276 ob_start();
277 readfile($file_to_send, "r");//this file contains the HTML to be converted to pdf.
278 //echo $file;
279 $content = ob_get_clean();
281 // Fix a nasty html2pdf bug - it ignores document root!
282 global $web_root, $webserver_root;
283 $i = 0;
284 $wrlen = strlen($web_root);
285 $wsrlen = strlen($webserver_root);
286 while (true) {
287 $i = stripos($content, " src='/", $i + 1);
288 if ($i === false) {
289 break;
292 if (substr($content, $i + 6, $wrlen) === $web_root &&
293 substr($content, $i + 6, $wsrlen) !== $webserver_root) {
294 $content = substr($content, 0, $i + 6) . $webserver_root . substr($content, $i + 6 + $wrlen);
298 $pdf2->WriteHTML($content);
299 $temp_filename = $STMT_TEMP_FILE_PDF;
300 $content_pdf = $pdf2->Output($STMT_TEMP_FILE_PDF, 'F');
301 } else {
302 $pdf = new Cezpdf('LETTER');//pdf creation starts
303 $pdf->ezSetMargins(45, 9, 36, 10);
304 $pdf->selectFont('Courier');
305 $pdf->ezSetY($pdf->ez['pageHeight'] - $pdf->ez['topMargin']);
306 $countline = 1;
307 $file = fopen($file_to_send, "r");//this file contains the text to be converted to pdf.
308 while (!feof($file)) {
309 $OneLine = fgets($file);//one line is read
310 if (stristr($OneLine, "\014") == true && !feof($file)) {//form feed means we should start a new page.
311 $pdf->ezNewPage();
312 $pdf->ezSetY($pdf->ez['pageHeight'] - $pdf->ez['topMargin']);
313 str_replace("\014", "", $OneLine);
316 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.
317 $pdf->ezText('<b>' . $OneLine . '</b>', 12, array('justification' => 'left', 'leading' => 6));
318 } else {
319 $pdf->ezText($OneLine, 12, array('justification' => 'left', 'leading' => 6));
322 $countline++;
325 $fh = @fopen($STMT_TEMP_FILE_PDF, 'w');//stored to a pdf file
326 if ($fh) {
327 fwrite($fh, $pdf->ezOutput());
328 fclose($fh);
332 header("Pragma: public");//this section outputs the pdf file to browser
333 header("Expires: 0");
334 header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
335 header("Content-Type: application/force-download");
336 header("Content-Length: " . filesize($STMT_TEMP_FILE_PDF));
337 header("Content-Disposition: attachment; filename=" . basename($STMT_TEMP_FILE_PDF));
338 header("Content-Description: File Transfer");
339 readfile($STMT_TEMP_FILE_PDF);
340 // flush the content to the browser. If you don't do this, the text from the subsequent
341 // output from this script will be in the file instead of sent to the browser.
342 flush();
343 exit(); //added to exit from process properly in order to stop bad html code -ehrlive
344 // sleep one second to ensure there's no follow-on.
345 sleep(1);
349 $today = date("Y-m-d");
350 // Print or download statements if requested.
352 if (($_REQUEST['form_print'] || $_REQUEST['form_download'] || $_REQUEST['form_email'] || $_REQUEST['form_pdf']) || $_REQUEST['form_portalnotify'] && $_REQUEST['form_cb']) {
353 if (!verifyCsrfToken($_REQUEST["csrf_token_form"])) {
354 csrfNotVerified();
357 $fhprint = fopen($STMT_TEMP_FILE, 'w');
359 $sqlBindArray = array();
360 $where = "";
361 foreach ($_REQUEST['form_cb'] as $key => $value) {
362 $where .= " OR f.id = ?";
363 array_push($sqlBindArray, $key);
366 if (!empty($where)) {
367 $where = substr($where, 4);
368 $where = '( ' . $where . ' ) AND';
371 $res = sqlStatement("SELECT " .
372 "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, " .
373 "p.fname, p.mname, p.lname, p.street, p.city, p.state, p.postal_code, p.billing_note as pat_billing_note " .
374 "FROM form_encounter AS f, patient_data AS p " .
375 "WHERE $where " .
376 "p.pid = f.pid " .
377 "ORDER BY p.lname, p.fname, f.pid, f.date, f.encounter", $sqlBindArray);
379 $stmt = array();
380 $stmt_count = 0;
382 $flagT = true;
383 $aPatientFirstName = '';
384 $aPatientID = null;
385 $multiplePatients = false;
386 $usePatientNamePdf = false;
388 // get pids for delimits
389 // need to only use summary invoice for multi visits
390 $inv_pid = array();
391 $inv_count = -1;
392 if ($_REQUEST['form_portalnotify']) {
393 foreach ($_REQUEST['form_invpids'] as $key => $v) {
394 if ($_REQUEST['form_cb'][$key]) {
395 array_push($inv_pid, key($v));
399 $rcnt = 0;
400 while ($row = sqlFetchArray($res)) {
401 $rows[] = $row;
402 if (!$inv_pid[$rcnt]) {
403 array_push($inv_pid, $row['pid']);
405 $rcnt++;
407 // This loops once for each invoice/encounter.
409 $rcnt = 0;
410 while ($row = $rows[$rcnt++]) {
411 $svcdate = substr($row['date'], 0, 10);
412 $duedate = $svcdate; // TBD?
413 $duncount = $row['stmt_count'];
414 $enc_note = $row['enc_billing_note'];
416 if ($flagT) {
417 $flagT = false;
418 $aPatientFirstName = $row['fname'];
419 $aPatientID = $row['pid'];
420 $usePatientNamePdf = true;
421 } elseif (!$multiplePatients) {
422 if ($aPatientID != $row['pid']) {
423 $multiplePatients = true;
424 $aPatientFirstName = '';
425 $aPatientID = null;
426 $usePatientNamePdf = false;
430 // If this is a new patient then print the pending statement
431 // and start a new one. This is an associative array:
433 // cid = same as pid
434 // pid = OpenEMR patient ID
435 // patient = patient name
436 // amount = total amount due
437 // adjust = adjustments (already applied to amount)
438 // duedate = due date of the oldest included invoice
439 // age = number of days from duedate to today
440 // to = array of addressee name/address lines
441 // lines = array of:
442 // dos = date of service "yyyy-mm-dd"
443 // desc = description
444 // amount = charge less adjustments
445 // paid = amount paid
446 // notice = 1 for first notice, 2 for second, etc.
447 // detail = array of details, see invoice_summary.inc.php
449 if ($stmt['cid'] != $row['pid']) {
450 if (!empty($stmt)) {
451 ++$stmt_count;
454 $stmt['cid'] = $row['pid'];
455 $stmt['pid'] = $row['pid'];
456 $stmt['dun_count'] = $row['stmt_count'];
457 $stmt['bill_note'] = $row['pat_billing_note'];
458 $stmt['enc_bill_note'] = $row['enc_billing_note'];
459 $stmt['bill_level'] = $row['last_level_billed'];
460 $stmt['level_closed'] = $row['last_level_closed'];
461 $stmt['patient'] = $row['fname'] . ' ' . $row['lname'];
462 $stmt['encounter'] = $row['encounter'];
463 #If you use the field in demographics layout called
464 #guardiansname this will allow you to send statements to the parent
465 #of a child or a guardian etc
466 if (strlen($row['guardiansname']) == 0) {
467 $stmt['to'] = array($row['fname'] . ' ' . $row['lname']);
468 } else {
469 $stmt['to'] = array($row['guardiansname']);
472 if ($row['street']) {
473 $stmt['to'][] = $row['street'];
476 $stmt['to'][] = $row['city'] . ", " . $row['state'] . " " . $row['postal_code'];
477 $stmt['lines'] = array();
478 $stmt['amount'] = '0.00';
479 $stmt['ins_paid'] = 0;
480 $stmt['today'] = $today;
481 $stmt['duedate'] = $duedate;
482 } else {
483 // Report the oldest due date.
484 if ($duedate < $stmt['duedate']) {
485 $stmt['duedate'] = $duedate;
489 // Recompute age at each invoice.
490 $stmt['age'] = round((strtotime($today) - strtotime($stmt['duedate'])) / (24 * 60 * 60));
492 $invlines = ar_get_invoice_summary($row['pid'], $row['encounter'], true);
493 foreach ($invlines as $key => $value) {
494 $line = array();
495 $line['dos'] = $svcdate;
496 if ($GLOBALS['use_custom_statement']) {
497 $line['desc'] = ($key == 'CO-PAY') ? "Patient Payment" : $value['code_text'];
498 } else {
499 $line['desc'] = ($key == 'CO-PAY') ? "Patient Payment" : "Procedure $key";
502 $line['amount'] = sprintf("%.2f", $value['chg']);
503 $line['adjust'] = sprintf("%.2f", $value['adj']);
504 $line['paid'] = sprintf("%.2f", $value['chg'] - $value['bal']);
505 $line['notice'] = $duncount + 1;
506 $line['detail'] = $value['dtl'];
507 $stmt['lines'][] = $line;
508 $stmt['amount'] = sprintf("%.2f", $stmt['amount'] + $value['bal']);
509 $stmt['ins_paid'] = $stmt['ins_paid'] + $value['ins'];
512 // Record that this statement was run.
513 if (!$DEBUG && !$_REQUEST['form_without']) {
514 sqlStatement("UPDATE form_encounter SET " .
515 "last_stmt_date = ?, stmt_count = stmt_count + 1 " .
516 "WHERE id = ?", array($today, $row['id']));
518 $inv_count += 1;
519 if ($_REQUEST['form_portalnotify']) {
520 if (!is_auth_portal($stmt['pid'])) {
521 $alertmsg = xlt('Notification FAILED: Not Portal Authorized');
522 break;
524 $pvoice[] = $stmt;
525 // we don't want to send the portal multiple invoices, thus this. Last invoice for pid is summary.
526 if ($inv_pid[$inv_count] != $inv_pid[$inv_count + 1]) {
527 fwrite($fhprint, make_statement($stmt));
528 if (!notify_portal($stmt['pid'], $pvoice, $STMT_TEMP_FILE, $stmt['pid'] . "-" . $stmt['encounter'])) {
529 $alertmsg = xlt('Notification FAILED');
530 break;
533 $pvoice = array();
534 flush();
535 ftruncate($fhprint, 0);
536 } else {
537 continue;
539 } else {
540 if ($inv_pid[$inv_count] != $inv_pid[$inv_count + 1]) {
541 $tmp = make_statement($stmt);
542 if (empty($tmp)) {
543 $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";
544 $tmp .= "<br />\n\014<br /><br />";
546 fwrite($fhprint, $tmp);
549 } // end while
551 if (!empty($stmt)) {
552 ++$stmt_count;
555 fclose($fhprint);
556 sleep(1);
557 // Download or print the file, as selected
558 if ($_REQUEST['form_download']) {
559 upload_file_to_client($STMT_TEMP_FILE);
560 } elseif ($_REQUEST['form_pdf']) {
561 upload_file_to_client_pdf($STMT_TEMP_FILE, $aPatientFirstName, $aPatientID, $usePatientNamePdf);
562 } elseif ($_REQUEST['form_email']) {
563 upload_file_to_client_email($stmt['pid'], $STMT_TEMP_FILE);
564 } elseif ($_REQUEST['form_portalnotify']) {
565 if ($alertmsg == "") {
566 $alertmsg = xl('Sending Invoice to Patient Portal Completed');
568 } else { // Must be print!
569 if ($DEBUG) {
570 $alertmsg = xl("Printing skipped; see test output in") . ' ' . $STMT_TEMP_FILE;
571 } else {
572 exec(escapeshellcmd($STMT_PRINT_CMD) . " " . escapeshellarg($STMT_TEMP_FILE));
573 if ($_REQUEST['form_without']) {
574 $alertmsg = xl('Now printing') . ' ' . $stmt_count . ' ' . xl('statements; invoices will not be updated.');
575 } else {
576 $alertmsg = xl('Now printing') . ' ' . $stmt_count . ' ' . xl('statements and updating invoices.');
578 } // end not debug
579 } // end not form_download
580 } // end statements requested
582 <html>
583 <head>
584 <?php Header::setupHeader(['datetime-picker']); ?>
585 <title><?php echo xlt('EOB Posting - Search'); ?></title>
586 <script language="JavaScript">
587 var mypcc = '1';
589 function checkAll(checked) {
590 var f = document.forms[0];
591 for (var i = 0; i < f.elements.length; ++i) {
592 var ename = f.elements[i].name;
593 if (ename.indexOf('form_cb[') == 0)
594 f.elements[i].checked = checked;
598 function persistCriteria(el, e) {
599 e.preventDefault();
600 let target = "sl_eob_search.posting_adj_disable";
601 let val = el.checked ? 'checked' : '';
602 $.post("./../../library/ajax/user_settings.php",
604 target: target,
605 setting: val,
606 csrf_token_form: "<?php echo attr(collectCsrfToken()); ?>"
611 function npopup(pid) {
612 window.open('sl_eob_patient_note.php?patient_id=' + pid, '_blank', 'width=500,height=250,resizable=1');
613 return false;
616 function toEncSummary(pid) {
617 // Tabs only
618 top.restoreSession();
619 let encurl = 'patient_file/history/encounters.php?billing=1&issue=0&pagesize=20&pagestart=0';
620 let paturl = "patient_file/summary/demographics.php?set_pid=" + pid;
621 parent.left_nav.loadFrame('pat2', 'pat', paturl);
622 // need a little time so can force a billing view
623 setTimeout(function(){parent.left_nav.loadFrame('enc2', 'enc', encurl);}, 3000);
626 $(document).ready(function () {
627 $('.datepicker').datetimepicker({
628 <?php $datetimepicker_timepicker = false; ?>
629 <?php $datetimepicker_showseconds = false; ?>
630 <?php $datetimepicker_formatInput = false; ?>
631 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
632 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
636 </script>
637 <style>
638 @media only screen and (max-width: 768px) {
639 [class*="col-"] {
640 width: 100%;
641 text-align: left !Important;
645 @media only screen and (max-width: 1004px) and (min-width: 641px) {
646 .oe-large {
647 display: none;
650 .oe-small {
651 display: inline-block;
655 @media print {
656 body * {
657 visibility: hidden;
660 .modal-body, .modal-body * {
661 visibility: visible;
664 .modal-body {
665 position: absolute;
666 left: 0;
667 top: 0;
668 width: 100%;
669 height: 10000px;
672 </style>
673 <?php
674 if ($GLOBALS['enable_help'] == 1) {
675 $help_icon = '<a class="pull-right oe-help-redirect" data-target="#myModal" data-toggle="modal" href="#" id="help-href" name="help-href" style="color:#676666" title="' . xla("Click to view Help") . '"><i class="fa fa-question-circle" aria-hidden="true"></i></a>';
676 } elseif ($GLOBALS['enable_help'] == 2) {
677 $help_icon = '<a class="pull-right oe-help-redirect" data-target="#myModal" data-toggle="modal" href="#" id="help-href" name="help-href" style="color:#DCD6D0 !Important" title="' . xla("Enable help in Administration > Globals > Features > Enable Help Modal") . '"><i class="fa fa-question-circle" aria-hidden="true"></i></a>';
678 } elseif ($GLOBALS['enable_help'] == 0) {
679 $help_icon = '';
682 <?php
683 //to determine and set the form to open in the desired state - expanded or centered, any selection the user makes will
684 //become the user-specific default for that page. collectAndOrganizeExpandSetting() contains a single array as an
685 //argument, containing one or more elements, the name of the current file is the first element, if there are linked
686 // files they should be listed thereafter, please add _xpd suffix to the file name
687 $arr_files_php = array("sl_eob_search_xpd");
688 $current_state = collectAndOrganizeExpandSetting($arr_files_php);
689 require_once("$srcdir/expand_contract_inc.php");
692 </head>
694 <body>
695 <div class="<?php echo $container; ?> expandable">
696 <div class="row">
697 <div class="col-sm-12">
698 <div class="page-header">
699 <h2 class="clearfix"><span id='header_text'><?php echo xlt('EOB Posting - Search'); ?></span> <i
700 id="exp_cont_icon"
701 class="fa <?php echo attr($expand_icon_class); ?> oe-superscript-small expand_contract"
702 title="<?php echo attr($expand_title); ?>" aria-hidden="true"></i> <a href='sl_eob_search.php'
703 onclick='top.restoreSession()'
704 title="<?php echo xla('Reset'); ?>">
705 <i id='advanced-tooltip' class='fa fa-undo fa-2x small' aria-hidden='true'></i>
706 </a><?php echo $help_icon; ?>
707 </h2>
708 </div>
709 </div>
710 </div>
711 <div class="row">
712 <div class="col-sm-12">
713 <form id="formSearch" action="" enctype='multipart/form-data' method='post'>
714 <input type="hidden" name="csrf_token_form" value="<?php echo attr(collectCsrfToken()); ?>"/>
715 <fieldset id="payment-allocate" class="oe-show-hide">
716 <legend>
717 &nbsp;<?php echo xlt('Post Item'); ?><i id="payment-info-do-not-remove"> </i>
718 </legend>
719 <div class="col-xs-12 oe-custom-line">
720 <div class="col-xs-3">
721 <label class="control-label" for="form_payer_id"> <?php echo xlt('Payer'); ?>:</label>
722 <?php
723 $insurancei = getInsuranceProviders();
724 echo " <select name='form_payer_id'id='form_payer_id' class='form-control'>\n";
725 echo " <option value='0'>-- " . xlt('Patient') . " --</option>\n";
726 foreach ($insurancei as $iid => $iname) {
727 echo "<option value='" . attr($iid) . "'";
728 if ($iid == $_REQUEST['form_payer_id']) {
729 echo " selected";
731 echo ">" . text($iname) . "</option>\n";
733 echo " </select>\n";
735 </div>
736 <div class="col-xs-2">
737 <label class="control-label" for="form_source"><?php echo xlt('Source'); ?>:</label>
738 <input type='text' name='form_source' id='form_source' class='form-control'
739 value='<?php echo attr($_REQUEST['form_source']); ?>'
740 title='<?php echo xla("A check number or claim number to identify the payment"); ?>'>
741 </div>
742 <div class="col-xs-2">
743 <label class="control-label" for="form_paydate"><?php echo xlt('Pay Date'); ?>:</label>
744 <input type='text' name='form_paydate' id='form_paydate' class='form-control datepicker'
745 value='<?php echo attr($_REQUEST['form_paydate']); ?>'
746 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)'
747 title='<?php echo xla("Date of payment yyyy-mm-dd"); ?>'>
748 </div>
749 <div class="col-xs-2">
750 <label class="control-label oe-large"
751 for="form_deposit_date"><?php echo xlt('Deposit Date'); ?>:</label>
752 <label class="control-label oe-small" for="form_deposit_date"><?php echo xlt('Dep Date'); ?>
753 :</label>
754 <input type='text' name='form_deposit_date' id='form_deposit_date'
755 class='form-control datepicker'
756 value='<?php echo attr($_REQUEST['form_deposit_date']); ?>'
757 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)'
758 title='<?php echo xla("Date of bank deposit yyyy-mm-dd"); ?>'>
759 </div>
760 <div class="col-xs-2">
761 <label class="control-label" for="form_amount"><?php echo xlt('Amount'); ?>:</label>
762 <input type='text' name='form_amount' id='form_amount' class='form-control'
763 value='<?php echo attr($_REQUEST['form_amount']); ?>'
764 title='<?php echo xla("Paid amount that you will allocate"); ?>'>
765 </div>
766 <div class="col-xs-1">
767 <label class="control-label oe-large" for="only_with_debt"><?php echo xlt('Pt Debt'); ?>
768 :</label>
769 <label class="control-label oe-small" for="only_with_debt"><?php echo xlt('Debt'); ?>
770 :</label>
771 <div class="text-center">
772 <input <?php echo $_REQUEST['only_with_debt'] ? 'checked=checked' : ''; ?>
773 type="checkbox" name="only_with_debt" id="only_with_debt"/>
774 </div>
775 </div>
776 </div>
777 </fieldset>
778 <fieldset id="search-upload">
779 <legend>
780 &nbsp;<span><?php echo xlt('Select Method'); ?></span>&nbsp;<i id='select-method-tooltip'
781 class="fa fa-info-circle oe-superscript"
782 aria-hidden="true"></i>
783 <div id="radio-div" class="pull-right oe-legend-radio">
784 <label class="radio-inline">
785 <input type="radio" id="invoice_search" name="radio-search" onclick=""
786 value="inv-search"><?php echo xlt('Invoice Search'); ?>
787 </label>
788 <label class="radio-inline">
789 <input type="radio" id="era_upload" name="radio-search" onclick=""
790 value="era-upld"><?php echo xlt('ERA Upload'); ?>
791 </label>
792 </div>
794 <input type="hidden" id="hid1" value="<?php echo xla('Invoice Search'); ?>">
795 <input type="hidden" id="hid2" value="<?php echo xla('ERA Upload'); ?>">
796 <input type="hidden" id="hid3" value="<?php echo xla('Select Method'); ?>">
797 </legend>
798 <div class="col-xs-12 .oe-custom-line oe-show-hide" id='inv-search'>
799 <div class="col-xs-3">
800 <label class="control-label" for="form_name"><?php echo xlt('Name'); ?>:</label>
801 <input type='text' name='form_name' id='form_name' class='form-control'
802 value='<?php echo attr($_REQUEST['form_name']); ?>'
803 title='<?php echo xla("Any part of the patient name, or \"last,first\", or \"X-Y\""); ?>'
804 placeholder='<?php echo xla('Last name, First name'); ?>'>
805 </div>
806 <div class="col-xs-2">
807 <label class="control-label" for="form_pid"><?php echo xlt('Chart ID'); ?>:</label>
808 <input type='text' name='form_pid' id='form_pid' class='form-control'
809 value='<?php echo attr($_REQUEST['form_pid']); ?>'
810 title='<?php echo xla("Patient chart ID"); ?>'>
811 </div>
812 <div class="col-xs-2">
813 <label class="control-label" for="form_encounter"><?php echo xlt('Encounter'); ?>:</label>
814 <input type='text' name='form_encounter' id='form_encounter' class='form-control'
815 value='<?php echo attr($_REQUEST['form_encounter']); ?>'
816 title='<?php echo xla("Encounter number"); ?>'>
817 </div>
818 <div class="col-xs-2">
819 <label class="control-label oe-large"
820 for="form_date"><?php echo xlt('Service Date From'); ?>:</label>
821 <label class="control-label oe-small" for="form_date"><?php echo xlt('Svc Date'); ?>
822 :</label>
823 <input type='text' name='form_date' id='form_date' class='form-control datepicker'
824 value='<?php echo attr($_REQUEST['form_date']); ?>'
825 title='<?php echo xla("Date of service mm/dd/yyyy"); ?>'>
826 </div>
827 <div class="col-xs-2">
828 <label class="control-label" for="form_to_date"><?php echo xlt('Service Date To'); ?>
829 :</label>
830 <input type='text' name='form_to_date' id='form_to_date' class='form-control datepicker'
831 value='<?php echo attr($_REQUEST['form_to_date']); ?>'
832 title='<?php echo xla("Ending DOS mm/dd/yyyy if you wish to enter a range"); ?>'>
833 </div>
834 <div class="col-xs-1" style="padding-right:0px">
835 <label class="control-label" for="type_name"><?php echo xlt('Type'); ?>:</label>
836 <select name='form_category' id='form_category' class='form-control'>
837 <?php
838 foreach (array(xl('Open'), xl('All'), xl('Due Pt'), xl('Due Ins')) as $value) {
839 echo " <option value='" . attr($value) . "'";
840 if ($_REQUEST['form_category'] == $value) {
841 echo " selected";
843 echo ">" . text($value) . "</option>\n";
846 </select>
847 </div>
848 </div>
849 <div class="col-xs-12 .oe-custom-line oe-show-hide" id='era-upld'>
850 <div class="form-group col-xs9 oe-file-div">
851 <div class="input-group">
852 <label class="input-group-btn">
853 <span class="btn btn-default">Browse&hellip;<input type="file" id="uploadedfile" name="form_erafile" style="display: none;">
854 <input name="MAX_FILE_SIZE" type="hidden" value="5000000">
855 </span>
856 </label>
857 <input type="text" class="form-control"
858 placeholder="<?php echo xla('Click Browse and select one Electronic Remittance Advice (ERA) file...'); ?>"
859 readonly>
860 </div>
861 </div>
862 </div>
863 </fieldset>
864 <?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 ?>
865 <div class="form-group clearfix">
866 <div class="col-sm-12 position-override oe-show-hide" id="search-btn">
867 <div class="btn-group" role="group">
868 <button type='submit' class="btn btn-default btn-search oe-show-hide" name='form_search'
869 id="btn-inv-search"
870 value='<?php echo xla("Search"); ?>'><?php echo xlt("Search"); ?></button>
871 <button type='submit' class="btn btn-default btn-save oe-show-hide" name='form_search'
872 id="btn-era-upld"
873 value='<?php echo xla("Upload"); ?>'><?php echo xlt("Upload"); ?></button>
874 </div>
875 </div>
876 </div>
877 <fieldset id="search-results" class="oe-show-hide">
878 <legend><span><?php echo xlt('Search Results'); ?></span>
879 <div class="pull-right oe-legend-radio">
880 <label class="checkbox-inline">
881 <input type="checkbox" id="posting_adj_disable" name="posting_adj_disable"
882 onchange='persistCriteria(this, event)'
883 title="<?php echo xlt("Disable automatically calculating balance adjustments for invoice posting") ?>"
884 value="<?php echo attr($posting_adj_disable); ?>"
885 <?php echo ' ' . attr($posting_adj_disable); ?> /><?php echo xlt('Disable Auto Adjustments'); ?>
886 </label>
887 </div>
888 </legend>
889 <div class="table-responsive">
890 <?php
891 if ($_REQUEST['form_search'] || $_REQUEST['form_print']) {
892 if (!verifyCsrfToken($_REQUEST["csrf_token_form"])) {
893 csrfNotVerified();
896 $form_name = trim($_REQUEST['form_name']);
897 $form_pid = trim($_REQUEST['form_pid']);
898 $form_encounter = trim($_REQUEST['form_encounter']);
899 $form_date = fixDate($_REQUEST['form_date'], "");
900 $form_to_date = fixDate($_REQUEST['form_to_date'], "");
902 $where = "";
904 // Handle X12 835 file upload.
906 if ($_FILES['form_erafile']['size']) {
907 $tmp_name = $_FILES['form_erafile']['tmp_name'];
909 // Handle .zip extension if present. Probably won't work on Windows.
910 if (strtolower(substr($_FILES['form_erafile']['name'], -4)) == '.zip') {
911 rename($tmp_name, "$tmp_name.zip");
912 exec("unzip -p " . escapeshellarg($tmp_name . ".zip") . " > " . escapeshellarg($tmp_name));
913 unlink("$tmp_name.zip");
916 echo "<!-- Notes from ERA upload processing:\n";
917 $alertmsg .= parse_era($tmp_name, 'era_callback');
918 echo "-->\n";
919 $erafullname = $GLOBALS['OE_SITE_DIR'] . "/era/$eraname.edi";
921 if (is_file($erafullname)) {
922 $alertmsg .= "Warning: Set $eraname was already uploaded ";
923 if (is_file($GLOBALS['OE_SITE_DIR'] . "/era/$eraname.html")) {
924 $alertmsg .= "and processed. ";
925 } else {
926 $alertmsg .= "but not yet processed. ";
929 rename($tmp_name, $erafullname);
930 } // End 835 upload
932 if ($eracount) {
933 // Note that parse_era() modified $eracount and $where.
934 if (!$where) {
935 $where = '1 = 2';
937 } else {
938 if ($form_name) {
939 if ($where) {
940 $where .= " AND ";
942 // Allow the last name to be followed by a comma and some part of a first name.
943 if (preg_match('/^(.*\S)\s*,\s*(.*)/', $form_name, $matches)) {
944 $where .= "p.lname LIKE '" . add_escape_custom($matches[1]) . "%' AND p.fname LIKE '" . add_escape_custom($matches[2]) . "%'";
945 // Allow a filter like "A-C" on the first character of the last name.
946 } elseif (preg_match('/^(\S)\s*-\s*(\S)$/', $form_name, $matches)) {
947 $tmp = '1 = 2';
948 while (ord($matches[1]) <= ord($matches[2])) {
949 $tmp .= " OR p.lname LIKE '" . add_escape_custom($matches[1]) . "%'";
950 $matches[1] = chr(ord($matches[1]) + 1);
952 $where .= "( $tmp ) ";
953 } else {
954 $where .= "p.lname LIKE '%" . add_escape_custom($form_name) . "%'";
957 if ($form_pid) {
958 if ($where) {
959 $where .= " AND ";
961 $where .= "f.pid = '" . add_escape_custom($form_pid) . "'";
963 if ($form_encounter) {
964 if ($where) {
965 $where .= " AND ";
967 $where .= "f.encounter = '" . add_escape_custom($form_encounter) . "'";
969 if ($form_date) {
970 if ($where) {
971 $where .= " AND ";
973 if ($form_to_date) {
974 $where .= "f.date >= '" . add_escape_custom($form_date) . "' AND f.date <= '" . add_escape_custom($form_to_date) . "'";
975 } else {
976 $where .= "f.date = '" . add_escape_custom($form_date) . "'";
979 if (!$where) {
980 if ($_REQUEST['form_category'] == 'All') {
981 die(xlt("At least one search parameter is required if you select All."));
982 } else {
983 $where = "1 = 1";
988 // Notes that as of release 4.1.1 the copays are stored
989 // in the ar_activity table marked with a PCP in the account_code column.
990 $query = "SELECT f.id, f.pid, f.encounter, f.date, " .
991 "f.last_level_billed, f.last_level_closed, f.last_stmt_date, f.stmt_count, " .
992 "p.fname, p.mname, p.lname, p.pubpid, p.billing_note, " .
993 "( SELECT SUM(b.fee) FROM billing AS b WHERE " .
994 "b.pid = f.pid AND b.encounter = f.encounter AND " .
995 "b.activity = 1 AND b.code_type != 'COPAY' ) AS charges, " .
996 "( SELECT SUM(a.pay_amount) FROM ar_activity AS a WHERE " .
997 "a.pid = f.pid AND a.encounter = f.encounter AND a.payer_type = 0 AND a.account_code = 'PCP')*-1 AS copays, " .
998 "( SELECT SUM(a.pay_amount) FROM ar_activity AS a WHERE " .
999 "a.pid = f.pid AND a.encounter = f.encounter AND a.account_code != 'PCP') AS payments, " .
1000 "( SELECT SUM(a.adj_amount) FROM ar_activity AS a WHERE " .
1001 "a.pid = f.pid AND a.encounter = f.encounter ) AS adjustments " .
1002 "FROM form_encounter AS f " .
1003 "JOIN patient_data AS p ON p.pid = f.pid " .
1004 "WHERE $where " .
1005 "ORDER BY p.lname, p.fname, p.mname, f.pid, f.encounter";
1007 // Note that unlike the SQL-Ledger case, this query does not weed
1008 // out encounters that are paid up. Also the use of sub-selects
1009 // will require MySQL 4.1 or greater.
1011 // echo "<!-- $query -->\n"; // debugging
1013 $t_res = sqlStatement($query);
1015 $num_invoices = sqlNumRows($t_res);
1016 if ($eracount && $num_invoices != $eracount) {
1017 $alertmsg .= "Of $eracount remittances, there are $num_invoices " .
1018 "matching encounters in OpenEMR. ";
1021 <table class="table table-striped table-condensed">
1022 <thead>
1023 <tr>
1024 <th class="id dehead"><?php echo xlt('id'); ?></th>
1025 <th class="dehead">&nbsp;<?php echo xlt('Patient'); ?></th>
1026 <th class="dehead">&nbsp;<?php echo xlt('Invoice'); ?></th>
1027 <th class="dehead">&nbsp;<?php echo xlt('Svc Date'); ?></th>
1028 <th class="dehead">&nbsp;<?php echo xlt('Last Stmt'); ?></th>
1029 <th align="right" class="dehead"><?php echo xlt('Charge'); ?>&nbsp;</th>
1030 <th align="right" class="dehead"><?php echo xlt('Adjust'); ?>&nbsp;</th>
1031 <th align="right" class="dehead"><?php echo xlt('Paid'); ?>&nbsp;</th>
1032 <th align="right" class="dehead"><?php echo xlt('Balance'); ?>&nbsp;</th>
1033 <th align="center" class="dehead"><?php echo xlt('Prv'); ?></th>
1034 <?php
1035 if (!$eracount) { ?>
1036 <th align="left" class="dehead"><?php echo xlt('Sel'); ?></th>
1037 <th align="center" class="dehead"><?php echo xlt('Email'); ?></th>
1038 <?php
1039 } ?>
1040 </tr>
1041 </thead>
1042 <?php
1043 $orow = -1;
1045 while ($row = sqlFetchArray($t_res)) {
1046 $balance = sprintf("%.2f", $row['charges'] + $row['copays'] - $row['payments'] - $row['adjustments']);
1047 //new filter only patients with debt.
1048 if ($_REQUEST['only_with_debt'] && $balance <= 0) {
1049 continue;
1053 if ($_REQUEST['form_category'] != 'All' && $eracount == 0 && $balance == 0) {
1054 continue;
1057 // $duncount was originally supposed to be the number of times that
1058 // the patient was sent a statement for this invoice.
1060 $duncount = $row['stmt_count'];
1062 // But if we have not yet billed the patient, then compute $duncount as a
1063 // negative count of the number of insurance plans for which we have not
1064 // yet closed out insurance.
1066 if (!$duncount) {
1067 for ($i = 1; $i <= 3 && arGetPayerID($row['pid'], $row['date'], $i);
1068 ++$i) {
1070 $duncount = $row['last_level_closed'] + 1 - $i;
1073 $isdueany = ($balance > 0);
1075 // An invoice is now due from the patient if money is owed and we are
1076 // not waiting for insurance to pay.
1078 $isduept = ($duncount >= 0 && $isdueany) ? " checked" : "";
1080 // Skip invoices not in the desired "Due..." category.
1082 if (substr($_REQUEST['form_category'], 0, 3) == 'Due' && !$isdueany) {
1083 continue;
1085 if ($_REQUEST['form_category'] == 'Due Ins' && ($duncount >= 0 || !$isdueany)) {
1086 continue;
1088 if ($_REQUEST['form_category'] == 'Due Pt' && ($duncount < 0 || !$isdueany)) {
1089 continue;
1092 $bgcolor = ((++$orow & 1) ? "#ffdddd" : "#ddddff");
1094 $svcdate = substr($row['date'], 0, 10);
1095 $last_stmt_date = empty($row['last_stmt_date']) ? '' : $row['last_stmt_date'];
1097 // Determine if customer is in collections.
1099 $billnote = $row['billing_note'];
1100 $in_collections = stristr($billnote, 'IN COLLECTIONS') !== false;
1102 <tr>
1103 <td class="detail">
1104 <a href=""
1105 onclick="return npopup(<?php echo attr(addslashes($row['pid'])) ?>)"><?php echo text($row['pid']); ?></a>
1106 </td>
1107 <td class="detail">&nbsp;
1108 <a href=""
1109 onclick="return npopup(<?php echo attr(addslashes($row['pid'])) ?>)"><?php echo text($row['lname']) . ', ' . text($row['fname']); ?></a>
1110 </td>
1111 <td class="detail">&nbsp;
1112 <a href="sl_eob_invoice.php?id=<?php echo attr(urlencode($row['id'])); ?>"
1113 target="_blank"><?php echo text($row['pid']) . '.' . text($row['encounter']); ?></a>
1114 </td>
1115 <td class="detail">&nbsp;<?php echo text(oeFormatShortDate($svcdate)); ?></td>
1116 <td class="detail">
1117 &nbsp;<?php echo text(oeFormatShortDate($last_stmt_date)); ?></td>
1118 <td align="right" class="detail"><?php echo text(bucks($row['charges'])); ?>&nbsp;
1119 </td>
1120 <td align="right" class="detail"><?php echo text(bucks($row['adjustments'])); ?>
1121 &nbsp;
1122 </td>
1123 <td align="right"
1124 class="detail"><?php echo text(bucks($row['payments'] - $row['copays'])); ?>
1125 &nbsp;
1126 </td>
1127 <td align="right" class="detail"><?php echo text(bucks($balance)); ?>&nbsp;</td>
1128 <td align="center"
1129 class="detail"><?php echo $duncount ? text($duncount) : "&nbsp;" ?></td>
1130 <?php if (!$eracount) { ?>
1131 <td class="detail" align="left">
1132 <input type='checkbox'
1133 name='form_cb[<?php echo attr($row['id']) ?>]'<?php echo text($isduept); ?> />
1134 <?php
1135 if ($in_collections) {
1136 echo "<b><font color='red'>IC</font></b>";
1137 } ?>
1138 <?php
1139 if (function_exists('is_auth_portal') ? is_auth_portal($row['pid']) : false) {
1140 echo(' PPt');
1141 echo("<input type='hidden' name='form_invpids[" . attr($row['id']) . "][" . attr($row['pid']) . "]' />");
1142 $is_portal = true;
1143 } ?>
1144 </td>
1145 <?php } ?>
1146 <td align="left" class="detail">
1147 <?php
1148 $patientData = sqlQuery("SELECT * FROM `patient_data` WHERE `pid`=?", array($row['pid']));
1149 if ($patientData['hipaa_allowemail'] == "YES" && $patientData['allow_patient_portal'] == "YES" && $patientData['hipaa_notice'] == "YES" && validEmail($patientData['email'])) {
1150 echo xlt("YES");
1151 } else {
1152 echo xlt("NO");
1155 </td>
1156 </tr>
1157 <?php
1158 } // end while
1159 } // end search/print logic
1161 </table>
1162 </div><!--End of table-responsive div-->
1163 </fieldset>
1164 <?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 ?>
1165 <div class="form-group clearfix">
1166 <div class="col-sm-12 text-left position-override oe-show-hide" id="statement-download">
1167 <div class="btn-group" role="group">
1168 <?php
1169 if ($eracount) { ?>
1170 <button type="button" class="btn btn-default btn-save" name="Submit"
1171 onclick='processERA()' value="<?php echo xla('Process ERA File'); ?>">
1172 <?php echo xlt('Process ERA File'); ?></button>
1173 <?php
1174 } else { ?>
1175 <button type="button" class="btn btn-default btn-save" name="Submit1"
1176 onclick='checkAll(true)'><?php echo xlt('Select All'); ?></button>
1177 <button type="button" class="btn btn-default btn-undo" name="Submit2"
1178 onclick='checkAll(false)'><?php echo xlt('Clear All'); ?></button>
1179 <?php if ($GLOBALS['statement_appearance'] != '1') { ?>
1180 <button type="submit" class="btn btn-default btn-print" name='form_print'
1181 value="<?php echo xla('Print Selected Statements'); ?>">
1182 <?php echo xlt('Print Selected Statements'); ?></button>
1183 <button type="submit" class="btn btn-default btn-download" name='form_download'
1184 value="<?php echo xla('Download Selected Statements'); ?>">
1185 <?php echo xlt('Download Selected Statements'); ?></button>
1186 <?php } ?>
1187 <button type="submit" class="btn btn-default btn-download" name='form_pdf'
1188 value="<?php echo xla('PDF Download Selected Statements'); ?>">
1189 <?php echo xlt('PDF Download Selected Statements'); ?></button>
1190 <button type="submit" class="btn btn-default btn-mail" name='form_download'
1191 value="<?php echo xla('Email Selected Statements'); ?>">
1192 <?php echo xlt('Email Selected Statements'); ?></button>
1193 <?php
1194 if ($is_portal) { ?>
1195 <button type="submit" class="btn btn-default btn-save" name='form_portalnotify'
1196 value="<?php echo xla('Notify via Patient Portal'); ?>">
1197 <?php echo xlt('Notify via Patient Portal'); ?></button>
1198 <?php
1202 <input type='checkbox' class="btn-separate-left" name='form_without'
1203 value='1'/><?php echo xlt('Without Update'); ?>
1204 </div>
1205 </div>
1206 </div>
1207 </form>
1208 </div>
1209 </div>
1210 </div> <!--End of Container div-->
1211 <br>
1212 <?php
1213 //home of the help modal ;)
1214 //$GLOBALS['enable_help'] = 0; // Please comment out line if you want help modal to function on this page
1215 if ($GLOBALS['enable_help'] == 1) {
1216 echo "<script>var helpFile = 'sl_eob_help.php'</script>";
1217 //help_modal.php lives in interface, set path accordingly
1218 require_once "../help_modal.php";
1221 <script language="JavaScript">
1222 function processERA() {
1223 var f = document.forms[0];
1224 var debug = f.form_without.checked ? '1' : '0';
1225 var paydate = f.form_paydate.value;
1226 window.open('sl_eob_process.php?eraname=<?php echo attr(urlencode($eraname)); ?>&debug=' + debug + '&paydate=' + paydate + '&original=original' + '&csrf_token_form=<?php echo attr(urlencode(collectCsrfToken())); ?>', '_blank');
1227 return false;
1230 $(function () {
1231 //https://www.abeautifulsite.net/whipping-file-inputs-into-shape-with-bootstrap-3
1232 // We can attach the `fileselect` event to all file inputs on the page
1233 $(document).on('change', ':file', function () {
1234 var input = $(this),
1235 numFiles = input.get(0).files ? input.get(0).files.length : 1,
1236 label = input.val().replace(/\\/g, '/').replace(/.*\//, '');
1237 input.trigger('fileselect', [numFiles, label]);
1240 // We can watch for our custom `fileselect` event like this
1241 $(document).ready(function () {
1242 $(':file').on('fileselect', function (event, numFiles, label) {
1243 var input = $(this).parents('.input-group').find(':text'),
1244 log = numFiles > 1 ? numFiles + ' files selected' : label;
1246 if (input.length) {
1247 input.val(log);
1249 else {
1250 if (log) alert(log);
1256 //to dynamically show /hide relevant divs and change Fieldset legends
1257 $(document).ready(function () {
1258 $("input[name=radio-search]").on("change", function () {
1260 let flip = $(this).val();
1261 $(".oe-show-hide").hide();
1262 $("#" + flip).show();
1263 if (flip == 'inv-search') {
1264 $("#search-upload").insertAfter("#payment-allocate");
1265 $('#payment-allocate').show();
1266 $('#search-btn').show();
1267 $('#btn-inv-search').show();
1268 var legend_text = $('#hid1').val();
1269 $('#search-upload').find('legend').find('span').text(legend_text);
1270 $('#search-upload').find('#form_name').focus();
1271 $('#select-method-tooltip').hide();
1273 else if (flip == 'era-upld') {
1274 $('#payment-allocate').hide();
1275 $('#search-btn').show();
1276 $('#btn-era-upld').show();
1277 var legend_text = $('#hid2').val();
1278 $('#search-upload').find('legend').find('span').text(legend_text);
1279 $('#select-method-tooltip').hide();
1281 else {
1282 $('#payment-allocate').hide();
1283 $('#search-btn').hide();
1284 var legend_text = $('#hid3').val();
1285 $('#search-upload').find('legend').find('span').text(legend_text);
1286 $('#select-method-tooltip').show();
1290 <?php
1291 if ($alertmsg) {
1292 echo "alert('" . addslashes($alertmsg) . "');\n";
1296 $(document).ready(function () {
1297 //using jquery-ui-1-12-1 tooltip instead of bootstrap tooltip
1298 $('#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();
1300 </script>
1301 <?php
1302 $tr_str = xl('Search');
1303 if ($_REQUEST['form_search'] == "$tr_str") { ?>
1304 <script>
1305 $("#payment-allocate").insertAfter("#search-upload");
1306 $('#payment-allocate').show();
1307 $("#search-results").show();
1308 $("#statement-download").show();
1309 </script>
1310 <?php
1313 <?php
1314 $tr_str = xl('Upload');
1315 if ($_REQUEST['form_search'] == "$tr_str") { ?>
1316 <script>
1317 $('#era-upld').show();
1318 $('#search-results').show();
1319 $("#statement-download").show();
1320 </script>
1321 <?php
1324 <script>
1325 <?php
1326 // jQuery script to change expanded/centered state dynamically
1327 require_once("../expand_contract_js.php")
1329 </script>
1331 </body>
1332 </html>