code review fix
[openemr.git] / interface / billing / sl_eob_search.php
blobf4120b189b021b80d677cb4f37db24949a309c4c
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 die(xlt('Authentication Error'));
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", {target: target, setting: val});
605 function npopup(pid) {
606 window.open('sl_eob_patient_note.php?patient_id=' + pid, '_blank', 'width=500,height=250,resizable=1');
607 return false;
610 $(document).ready(function () {
611 $('.datepicker').datetimepicker({
612 <?php $datetimepicker_timepicker = false; ?>
613 <?php $datetimepicker_showseconds = false; ?>
614 <?php $datetimepicker_formatInput = false; ?>
615 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
616 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
620 </script>
621 <style>
622 @media only screen and (max-width: 768px) {
623 [class*="col-"] {
624 width: 100%;
625 text-align: left !Important;
629 @media only screen and (max-width: 1004px) and (min-width: 641px) {
630 .oe-large {
631 display: none;
634 .oe-small {
635 display: inline-block;
639 @media print {
640 body * {
641 visibility: hidden;
644 .modal-body, .modal-body * {
645 visibility: visible;
648 .modal-body {
649 position: absolute;
650 left: 0;
651 top: 0;
652 width: 100%;
653 height: 10000px;
656 </style>
657 <?php
658 if ($GLOBALS['enable_help'] == 1) {
659 $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>';
660 } elseif ($GLOBALS['enable_help'] == 2) {
661 $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>';
662 } elseif ($GLOBALS['enable_help'] == 0) {
663 $help_icon = '';
666 <?php
667 //to determine and set the form to open in the desired state - expanded or centered, any selection the user makes will
668 //become the user-specific default for that page. collectAndOrganizeExpandSetting() contains a single array as an
669 //argument, containing one or more elements, the name of the current file is the first element, if there are linked
670 // files they should be listed thereafter, please add _xpd suffix to the file name
671 $arr_files_php = array("sl_eob_search_xpd");
672 $current_state = collectAndOrganizeExpandSetting($arr_files_php);
673 require_once("$srcdir/expand_contract_inc.php");
676 </head>
678 <body>
679 <div class="<?php echo $container; ?> expandable">
680 <div class="row">
681 <div class="col-sm-12">
682 <div class="page-header">
683 <h2 class="clearfix"><span id='header_text'><?php echo xlt('EOB Posting - Search'); ?></span> <i
684 id="exp_cont_icon"
685 class="fa <?php echo attr($expand_icon_class); ?> oe-superscript-small expand_contract"
686 title="<?php echo attr($expand_title); ?>" aria-hidden="true"></i> <a href='sl_eob_search.php'
687 onclick='top.restoreSession()'
688 title="<?php echo xla('Reset'); ?>"><i
689 id='advanced-tooltip' class='fa fa-undo fa-2x small' aria-hidden='true'></i>
690 </a><?php echo $help_icon; ?>
691 </h2>
692 </div>
693 </div>
694 </div>
695 <div class="row">
696 <div class="col-sm-12">
697 <form id="formSearch" action="" enctype='multipart/form-data' method='get'>
698 <input type="hidden" name="csrf_token_form" value="<?php echo attr(collectCsrfToken()); ?>"/>
699 <fieldset id="payment-allocate" class="oe-show-hide">
700 <legend>
701 &nbsp;<?php echo xlt('Post Item'); ?><i id="payment-info-do-not-remove"> </i>
702 </legend>
703 <div class="col-xs-12 oe-custom-line">
704 <div class="col-xs-3">
705 <label class="control-label" for="form_payer_id"> <?php echo xlt('Payer'); ?>:</label>
706 <?php
707 $insurancei = getInsuranceProviders();
708 echo " <select name='form_payer_id'id='form_payer_id' class='form-control'>\n";
709 echo " <option value='0'>-- " . xlt('Patient') . " --</option>\n";
710 foreach ($insurancei as $iid => $iname) {
711 echo "<option value='" . attr($iid) . "'";
712 if ($iid == $_REQUEST['form_payer_id']) {
713 echo " selected";
715 echo ">" . text($iname) . "</option>\n";
717 echo " </select>\n";
719 </div>
720 <div class="col-xs-2">
721 <label class="control-label" for="form_source"><?php echo xlt('Source'); ?>:</label>
722 <input type='text' name='form_source' id='form_source' class='form-control'
723 value='<?php echo attr($_REQUEST['form_source']); ?>'
724 title='<?php echo xla("A check number or claim number to identify the payment"); ?>'>
725 </div>
726 <div class="col-xs-2">
727 <label class="control-label" for="form_paydate"><?php echo xlt('Pay Date'); ?>:</label>
728 <input type='text' name='form_paydate' id='form_paydate' class='form-control datepicker'
729 value='<?php echo attr($_REQUEST['form_paydate']); ?>'
730 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)'
731 title='<?php echo xla("Date of payment yyyy-mm-dd"); ?>'>
732 </div>
733 <div class="col-xs-2">
734 <label class="control-label oe-large"
735 for="form_deposit_date"><?php echo xlt('Deposit Date'); ?>:</label>
736 <label class="control-label oe-small" for="form_deposit_date"><?php echo xlt('Dep Date'); ?>
737 :</label>
738 <input type='text' name='form_deposit_date' id='form_deposit_date'
739 class='form-control datepicker'
740 value='<?php echo attr($_REQUEST['form_deposit_date']); ?>'
741 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)'
742 title='<?php echo xla("Date of bank deposit yyyy-mm-dd"); ?>'>
743 </div>
744 <div class="col-xs-2">
745 <label class="control-label" for="form_amount"><?php echo xlt('Amount'); ?>:</label>
746 <input type='text' name='form_amount' id='form_amount' class='form-control'
747 value='<?php echo attr($_REQUEST['form_amount']); ?>'
748 title='<?php echo xla("Paid amount that you will allocate"); ?>'>
749 </div>
750 <div class="col-xs-1">
751 <label class="control-label oe-large" for="only_with_debt"><?php echo xlt('Pt Debt'); ?>
752 :</label>
753 <label class="control-label oe-small" for="only_with_debt"><?php echo xlt('Debt'); ?>
754 :</label>
755 <div class="text-center">
756 <input <?php echo $_REQUEST['only_with_debt'] ? 'checked=checked' : ''; ?>
757 type="checkbox" name="only_with_debt" id="only_with_debt"/>
758 </div>
759 </div>
760 </div>
761 </fieldset>
762 <fieldset id="search-upload">
763 <legend>
764 &nbsp;<span><?php echo xlt('Select Method'); ?></span>&nbsp;<i id='select-method-tooltip'
765 class="fa fa-info-circle oe-superscript"
766 aria-hidden="true"></i>
767 <div id="radio-div" class="pull-right oe-legend-radio">
768 <label class="radio-inline">
769 <input type="radio" id="invoice_search" name="radio-search" onclick=""
770 value="inv-search"><?php echo xlt('Invoice Search'); ?>
771 </label>
772 <label class="radio-inline">
773 <input type="radio" id="era_upload" name="radio-search" onclick=""
774 value="era-upld"><?php echo xlt('ERA Upload'); ?>
775 </label>
776 </div>
778 <input type="hidden" id="hid1" value="<?php echo xla('Invoice Search'); ?>">
779 <input type="hidden" id="hid2" value="<?php echo xla('ERA Upload'); ?>">
780 <input type="hidden" id="hid3" value="<?php echo xla('Select Method'); ?>">
781 </legend>
782 <div class="col-xs-12 .oe-custom-line oe-show-hide" id='inv-search'>
783 <div class="col-xs-3">
784 <label class="control-label" for="form_name"><?php echo xlt('Name'); ?>:</label>
785 <input type='text' name='form_name' id='form_name' class='form-control'
786 value='<?php echo attr($_REQUEST['form_name']); ?>'
787 title='<?php echo xla("Any part of the patient name, or \"last,first\", or \"X-Y\""); ?>'
788 placeholder='<?php echo xla('Last name, First name'); ?>'>
789 </div>
790 <div class="col-xs-2">
791 <label class="control-label" for="form_pid"><?php echo xlt('Chart ID'); ?>:</label>
792 <input type='text' name='form_pid' id='form_pid' class='form-control'
793 value='<?php echo attr($_REQUEST['form_pid']); ?>'
794 title='<?php echo xla("Patient chart ID"); ?>'>
795 </div>
796 <div class="col-xs-2">
797 <label class="control-label" for="form_encounter"><?php echo xlt('Encounter'); ?>:</label>
798 <input type='text' name='form_encounter' id='form_encounter' class='form-control'
799 value='<?php echo attr($_REQUEST['form_encounter']); ?>'
800 title='<?php echo xla("Encounter number"); ?>'>
801 </div>
802 <div class="col-xs-2">
803 <label class="control-label oe-large"
804 for="form_date"><?php echo xlt('Service Date From'); ?>:</label>
805 <label class="control-label oe-small" for="form_date"><?php echo xlt('Svc Date'); ?>
806 :</label>
807 <input type='text' name='form_date' id='form_date' class='form-control datepicker'
808 value='<?php echo attr($_REQUEST['form_date']); ?>'
809 title='<?php echo xla("Date of service mm/dd/yyyy"); ?>'>
810 </div>
811 <div class="col-xs-2">
812 <label class="control-label" for="form_to_date"><?php echo xlt('Service Date To'); ?>
813 :</label>
814 <input type='text' name='form_to_date' id='form_to_date' class='form-control datepicker'
815 value='<?php echo attr($_REQUEST['form_to_date']); ?>'
816 title='<?php echo xla("Ending DOS mm/dd/yyyy if you wish to enter a range"); ?>'>
817 </div>
818 <div class="col-xs-1" style="padding-right:0px">
819 <label class="control-label" for="type_name"><?php echo xlt('Type'); ?>:</label>
820 <select name='form_category' id='form_category' class='form-control'>
821 <?php
822 foreach (array(xl('Open'), xl('All'), xl('Due Pt'), xl('Due Ins')) as $value) {
823 echo " <option value='" . attr($value) . "'";
824 if ($_REQUEST['form_category'] == $value) {
825 echo " selected";
827 echo ">" . text($value) . "</option>\n";
830 </select>
831 </div>
832 </div>
833 <div class="col-xs-12 .oe-custom-line oe-show-hide" id='era-upld'>
834 <div class="form-group col-xs9 oe-file-div">
835 <div class="input-group">
836 <label class="input-group-btn">
837 <span class="btn btn-default">
838 Browse&hellip;<input type="file" id="uploadedfile" name="form_erafile"
839 style="display: none;">
840 <input name="MAX_FILE_SIZE" type="hidden" value="5000000">
841 </span>
842 </label>
843 <input type="text" class="form-control"
844 placeholder="<?php echo xla('Click Browse and select one Electronic Remittance Advice (ERA) file...'); ?>"
845 readonly>
846 </div>
847 </div>
848 </div>
849 </fieldset>
850 <?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 ?>
851 <div class="form-group clearfix">
852 <div class="col-sm-12 position-override oe-show-hide" id="search-btn">
853 <div class="btn-group" role="group">
854 <button type='submit' class="btn btn-default btn-search oe-show-hide" name='form_search'
855 id="btn-inv-search"
856 value='<?php echo xla("Search"); ?>'><?php echo xlt("Search"); ?></button>
857 <button type='submit' class="btn btn-default btn-save oe-show-hide" name='form_search'
858 id="btn-era-upld"
859 value='<?php echo xla("Upload"); ?>'><?php echo xlt("Upload"); ?></button>
860 </div>
861 </div>
862 </div>
863 <fieldset id="search-results" class="oe-show-hide">
864 <legend><span><?php echo xlt('Search Results'); ?></span>
865 <div class="pull-right oe-legend-radio">
866 <label class="checkbox-inline">
867 <input type="checkbox" id="posting_adj_disable" name="posting_adj_disable"
868 onchange='persistCriteria(this, event)'
869 title="<?php echo xlt("Disable automatically calculating balance adjustments for invoice posting") ?>"
870 value="<?php echo attr($posting_adj_disable); ?>"
871 <?php echo attr($posting_adj_disable); ?> /><?php echo xlt('Disable Auto Adjustments'); ?>
872 </label>
873 </div>
874 </legend>
875 <div class="table-responsive">
876 <?php
877 if ($_REQUEST['form_search'] || $_REQUEST['form_print']) {
878 if (!verifyCsrfToken($_REQUEST["csrf_token_form"])) {
879 die(xlt('Authentication Error'));
882 $form_name = trim($_REQUEST['form_name']);
883 $form_pid = trim($_REQUEST['form_pid']);
884 $form_encounter = trim($_REQUEST['form_encounter']);
885 $form_date = fixDate($_REQUEST['form_date'], "");
886 $form_to_date = fixDate($_REQUEST['form_to_date'], "");
888 $where = "";
890 // Handle X12 835 file upload.
892 if ($_FILES['form_erafile']['size']) {
893 $tmp_name = $_FILES['form_erafile']['tmp_name'];
895 // Handle .zip extension if present. Probably won't work on Windows.
896 if (strtolower(substr($_FILES['form_erafile']['name'], -4)) == '.zip') {
897 rename($tmp_name, "$tmp_name.zip");
898 exec("unzip -p " . escapeshellarg($tmp_name . ".zip") . " > " . escapeshellarg($tmp_name));
899 unlink("$tmp_name.zip");
902 echo "<!-- Notes from ERA upload processing:\n";
903 $alertmsg .= parse_era($tmp_name, 'era_callback');
904 echo "-->\n";
905 $erafullname = $GLOBALS['OE_SITE_DIR'] . "/era/$eraname.edi";
907 if (is_file($erafullname)) {
908 $alertmsg .= "Warning: Set $eraname was already uploaded ";
909 if (is_file($GLOBALS['OE_SITE_DIR'] . "/era/$eraname.html")) {
910 $alertmsg .= "and processed. ";
911 } else {
912 $alertmsg .= "but not yet processed. ";
915 rename($tmp_name, $erafullname);
916 } // End 835 upload
918 if ($eracount) {
919 // Note that parse_era() modified $eracount and $where.
920 if (!$where) {
921 $where = '1 = 2';
923 } else {
924 if ($form_name) {
925 if ($where) {
926 $where .= " AND ";
928 // Allow the last name to be followed by a comma and some part of a first name.
929 if (preg_match('/^(.*\S)\s*,\s*(.*)/', $form_name, $matches)) {
930 $where .= "p.lname LIKE '" . add_escape_custom($matches[1]) . "%' AND p.fname LIKE '" . add_escape_custom($matches[2]) . "%'";
931 // Allow a filter like "A-C" on the first character of the last name.
932 } elseif (preg_match('/^(\S)\s*-\s*(\S)$/', $form_name, $matches)) {
933 $tmp = '1 = 2';
934 while (ord($matches[1]) <= ord($matches[2])) {
935 $tmp .= " OR p.lname LIKE '" . add_escape_custom($matches[1]) . "%'";
936 $matches[1] = chr(ord($matches[1]) + 1);
938 $where .= "( $tmp ) ";
939 } else {
940 $where .= "p.lname LIKE '%" . add_escape_custom($form_name) . "%'";
943 if ($form_pid) {
944 if ($where) {
945 $where .= " AND ";
947 $where .= "f.pid = '" . add_escape_custom($form_pid) . "'";
949 if ($form_encounter) {
950 if ($where) {
951 $where .= " AND ";
953 $where .= "f.encounter = '" . add_escape_custom($form_encounter) . "'";
955 if ($form_date) {
956 if ($where) {
957 $where .= " AND ";
959 if ($form_to_date) {
960 $where .= "f.date >= '" . add_escape_custom($form_date) . "' AND f.date <= '" . add_escape_custom($form_to_date) . "'";
961 } else {
962 $where .= "f.date = '" . add_escape_custom($form_date) . "'";
965 if (!$where) {
966 if ($_REQUEST['form_category'] == 'All') {
967 die(xlt("At least one search parameter is required if you select All."));
968 } else {
969 $where = "1 = 1";
974 // Notes that as of release 4.1.1 the copays are stored
975 // in the ar_activity table marked with a PCP in the account_code column.
976 $query = "SELECT f.id, f.pid, f.encounter, f.date, " .
977 "f.last_level_billed, f.last_level_closed, f.last_stmt_date, f.stmt_count, " .
978 "p.fname, p.mname, p.lname, p.pubpid, p.billing_note, " .
979 "( SELECT SUM(b.fee) FROM billing AS b WHERE " .
980 "b.pid = f.pid AND b.encounter = f.encounter AND " .
981 "b.activity = 1 AND b.code_type != 'COPAY' ) AS charges, " .
982 "( SELECT SUM(a.pay_amount) FROM ar_activity AS a WHERE " .
983 "a.pid = f.pid AND a.encounter = f.encounter AND a.payer_type = 0 AND a.account_code = 'PCP')*-1 AS copays, " .
984 "( SELECT SUM(a.pay_amount) FROM ar_activity AS a WHERE " .
985 "a.pid = f.pid AND a.encounter = f.encounter AND a.account_code != 'PCP') AS payments, " .
986 "( SELECT SUM(a.adj_amount) FROM ar_activity AS a WHERE " .
987 "a.pid = f.pid AND a.encounter = f.encounter ) AS adjustments " .
988 "FROM form_encounter AS f " .
989 "JOIN patient_data AS p ON p.pid = f.pid " .
990 "WHERE $where " .
991 "ORDER BY p.lname, p.fname, p.mname, f.pid, f.encounter";
993 // Note that unlike the SQL-Ledger case, this query does not weed
994 // out encounters that are paid up. Also the use of sub-selects
995 // will require MySQL 4.1 or greater.
997 // echo "<!-- $query -->\n"; // debugging
999 $t_res = sqlStatement($query);
1001 $num_invoices = sqlNumRows($t_res);
1002 if ($eracount && $num_invoices != $eracount) {
1003 $alertmsg .= "Of $eracount remittances, there are $num_invoices " .
1004 "matching encounters in OpenEMR. ";
1007 <table class="table table-striped table-condensed">
1008 <thead>
1009 <tr>
1010 <th class="id dehead"><?php echo xlt('id'); ?></th>
1011 <th class="dehead">&nbsp;<?php echo xlt('Patient'); ?></th>
1012 <th class="dehead">&nbsp;<?php echo xlt('Invoice'); ?></th>
1013 <th class="dehead">&nbsp;<?php echo xlt('Svc Date'); ?></th>
1014 <th class="dehead">&nbsp;<?php echo xlt('Last Stmt'); ?></th>
1015 <th align="right" class="dehead"><?php echo xlt('Charge'); ?>&nbsp;</th>
1016 <th align="right" class="dehead"><?php echo xlt('Adjust'); ?>&nbsp;</th>
1017 <th align="right" class="dehead"><?php echo xlt('Paid'); ?>&nbsp;</th>
1018 <th align="right" class="dehead"><?php echo xlt('Balance'); ?>&nbsp;</th>
1019 <th align="center" class="dehead"><?php echo xlt('Prv'); ?></th>
1020 <?php
1021 if (!$eracount) { ?>
1022 <th align="left" class="dehead"><?php echo xlt('Sel'); ?></th>
1023 <th align="center" class="dehead"><?php echo xlt('Email'); ?></th>
1024 <?php
1025 } ?>
1026 </tr>
1027 </thead>
1028 <?php
1029 $orow = -1;
1031 while ($row = sqlFetchArray($t_res)) {
1032 $balance = sprintf("%.2f", $row['charges'] + $row['copays'] - $row['payments'] - $row['adjustments']);
1033 //new filter only patients with debt.
1034 if ($_REQUEST['only_with_debt'] && $balance <= 0) {
1035 continue;
1039 if ($_REQUEST['form_category'] != 'All' && $eracount == 0 && $balance == 0) {
1040 continue;
1043 // $duncount was originally supposed to be the number of times that
1044 // the patient was sent a statement for this invoice.
1046 $duncount = $row['stmt_count'];
1048 // But if we have not yet billed the patient, then compute $duncount as a
1049 // negative count of the number of insurance plans for which we have not
1050 // yet closed out insurance.
1052 if (!$duncount) {
1053 for ($i = 1; $i <= 3 && arGetPayerID($row['pid'], $row['date'], $i);
1054 ++$i) {
1056 $duncount = $row['last_level_closed'] + 1 - $i;
1059 $isdueany = ($balance > 0);
1061 // An invoice is now due from the patient if money is owed and we are
1062 // not waiting for insurance to pay.
1064 $isduept = ($duncount >= 0 && $isdueany) ? " checked" : "";
1066 // Skip invoices not in the desired "Due..." category.
1068 if (substr($_REQUEST['form_category'], 0, 3) == 'Due' && !$isdueany) {
1069 continue;
1071 if ($_REQUEST['form_category'] == 'Due Ins' && ($duncount >= 0 || !$isdueany)) {
1072 continue;
1074 if ($_REQUEST['form_category'] == 'Due Pt' && ($duncount < 0 || !$isdueany)) {
1075 continue;
1078 $bgcolor = ((++$orow & 1) ? "#ffdddd" : "#ddddff");
1080 $svcdate = substr($row['date'], 0, 10);
1081 $last_stmt_date = empty($row['last_stmt_date']) ? '' : $row['last_stmt_date'];
1083 // Determine if customer is in collections.
1085 $billnote = $row['billing_note'];
1086 $in_collections = stristr($billnote, 'IN COLLECTIONS') !== false;
1088 <tr>
1089 <td class="detail">
1090 <a href=""
1091 onclick="return npopup(<?php echo attr(addslashes($row['pid'])) ?>)"><?php echo text($row['pid']); ?></a>
1092 </td>
1093 <td class="detail">&nbsp;
1094 <a href=""
1095 onclick="return npopup(<?php echo attr(addslashes($row['pid'])) ?>)"><?php echo text($row['lname']) . ', ' . text($row['fname']); ?></a>
1096 </td>
1097 <td class="detail">&nbsp;
1098 <a href="sl_eob_invoice.php?id=<?php echo attr(urlencode($row['id'])); ?>"
1099 target="_blank"><?php echo text($row['pid']) . '.' . text($row['encounter']); ?></a>
1100 </td>
1101 <td class="detail">&nbsp;<?php echo text(oeFormatShortDate($svcdate)); ?></td>
1102 <td class="detail">
1103 &nbsp;<?php echo text(oeFormatShortDate($last_stmt_date)); ?></td>
1104 <td align="right" class="detail"><?php echo text(bucks($row['charges'])); ?>&nbsp;
1105 </td>
1106 <td align="right" class="detail"><?php echo text(bucks($row['adjustments'])); ?>
1107 &nbsp;
1108 </td>
1109 <td align="right"
1110 class="detail"><?php echo text(bucks($row['payments'] - $row['copays'])); ?>
1111 &nbsp;
1112 </td>
1113 <td align="right" class="detail"><?php echo text(bucks($balance)); ?>&nbsp;</td>
1114 <td align="center"
1115 class="detail"><?php echo $duncount ? text($duncount) : "&nbsp;" ?></td>
1116 <?php if (!$eracount) { ?>
1117 <td class="detail" align="left">
1118 <input type='checkbox'
1119 name='form_cb[<?php echo attr($row['id']) ?>]'<?php echo text($isduept); ?> />
1120 <?php
1121 if ($in_collections) {
1122 echo "<b><font color='red'>IC</font></b>";
1123 } ?>
1124 <?php
1125 if (function_exists('is_auth_portal') ? is_auth_portal($row['pid']) : false) {
1126 echo(' PPt');
1127 echo("<input type='hidden' name='form_invpids[" . attr($row['id']) . "][" . attr($row['pid']) . "]' />");
1128 $is_portal = true;
1129 } ?>
1130 </td>
1131 <?php } ?>
1132 <td align="left" class="detail">
1133 <?php
1134 $patientData = sqlQuery("SELECT * FROM `patient_data` WHERE `pid`=?", array($row['pid']));
1135 if ($patientData['hipaa_allowemail'] == "YES" && $patientData['allow_patient_portal'] == "YES" && $patientData['hipaa_notice'] == "YES" && validEmail($patientData['email'])) {
1136 echo xlt("YES");
1137 } else {
1138 echo xlt("NO");
1141 </td>
1142 </tr>
1143 <?php
1144 } // end while
1145 } // end search/print logic
1147 </table>
1148 </div><!--End of table-responsive div-->
1149 </fieldset>
1150 <?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 ?>
1151 <div class="form-group clearfix">
1152 <div class="col-sm-12 text-left position-override oe-show-hide" id="statement-download">
1153 <div class="btn-group" role="group">
1154 <?php
1155 if ($eracount) { ?>
1156 <button type="button" class="btn btn-default btn-save" name="Submit"
1157 onclick='processERA()' value="<?php echo xla('Process ERA File'); ?>">
1158 <?php echo xlt('Process ERA File'); ?></button>
1159 <?php
1160 } else { ?>
1161 <button type="button" class="btn btn-default btn-save" name="Submit1"
1162 onclick='checkAll(true)'><?php echo xlt('Select All'); ?></button>
1163 <button type="button" class="btn btn-default btn-undo" name="Submit2"
1164 onclick='checkAll(false)'><?php echo xlt('Clear All'); ?></button>
1165 <?php if ($GLOBALS['statement_appearance'] != '1') { ?>
1166 <button type="submit" class="btn btn-default btn-print" name='form_print'
1167 value="<?php echo xla('Print Selected Statements'); ?>">
1168 <?php echo xlt('Print Selected Statements'); ?></button>
1169 <button type="submit" class="btn btn-default btn-download" name='form_download'
1170 value="<?php echo xla('Download Selected Statements'); ?>">
1171 <?php echo xlt('Download Selected Statements'); ?></button>
1172 <?php } ?>
1173 <button type="submit" class="btn btn-default btn-download" name='form_pdf'
1174 value="<?php echo xla('PDF Download Selected Statements'); ?>">
1175 <?php echo xlt('PDF Download Selected Statements'); ?></button>
1176 <button type="submit" class="btn btn-default btn-mail" name='form_download'
1177 value="<?php echo xla('Email Selected Statements'); ?>">
1178 <?php echo xlt('Email Selected Statements'); ?></button>
1179 <?php
1180 if ($is_portal) { ?>
1181 <button type="submit" class="btn btn-default btn-save" name='form_portalnotify'
1182 value="<?php echo xla('Notify via Patient Portal'); ?>">
1183 <?php echo xlt('Notify via Patient Portal'); ?></button>
1184 <?php
1188 <input type='checkbox' class="btn-separate-left" name='form_without'
1189 value='1'/><?php echo xlt('Without Update'); ?>
1190 </div>
1191 </div>
1192 </div>
1193 </form>
1194 </div>
1195 </div>
1196 </div> <!--End of Container div-->
1197 <br>
1198 <?php
1199 //home of the help modal ;)
1200 //$GLOBALS['enable_help'] = 0; // Please comment out line if you want help modal to function on this page
1201 if ($GLOBALS['enable_help'] == 1) {
1202 echo "<script>var helpFile = 'sl_eob_help.php'</script>";
1203 //help_modal.php lives in interface, set path accordingly
1204 require_once "../help_modal.php";
1207 <script language="JavaScript">
1208 function processERA() {
1209 var f = document.forms[0];
1210 var debug = f.form_without.checked ? '1' : '0';
1211 var paydate = f.form_paydate.value;
1212 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');
1213 return false;
1216 $(function () {
1217 //https://www.abeautifulsite.net/whipping-file-inputs-into-shape-with-bootstrap-3
1218 // We can attach the `fileselect` event to all file inputs on the page
1219 $(document).on('change', ':file', function () {
1220 var input = $(this),
1221 numFiles = input.get(0).files ? input.get(0).files.length : 1,
1222 label = input.val().replace(/\\/g, '/').replace(/.*\//, '');
1223 input.trigger('fileselect', [numFiles, label]);
1226 // We can watch for our custom `fileselect` event like this
1227 $(document).ready(function () {
1228 $(':file').on('fileselect', function (event, numFiles, label) {
1229 var input = $(this).parents('.input-group').find(':text'),
1230 log = numFiles > 1 ? numFiles + ' files selected' : label;
1232 if (input.length) {
1233 input.val(log);
1235 else {
1236 if (log) alert(log);
1242 //to dynamically show /hide relevant divs and change Fieldset legends
1243 $(document).ready(function () {
1244 $("input[name=radio-search]").on("change", function () {
1246 var flip = $(this).val();
1247 $(".oe-show-hide").hide();
1248 $("#" + flip).show();
1249 if (flip == 'inv-search') {
1250 $("#search-upload").insertAfter("#payment-allocate");
1251 $('#payment-allocate').show();
1252 $('#search-btn').show();
1253 $('#btn-inv-search').show();
1254 var legend_text = $('#hid1').val();
1255 $('#search-upload').find('legend').find('span').text(legend_text);
1256 $('#search-upload').find('#form_name').focus();
1257 $('#select-method-tooltip').hide();
1259 else if (flip == 'era-upld') {
1260 $('#payment-allocate').hide();
1261 $('#search-btn').show();
1262 $('#btn-era-upld').show();
1263 var legend_text = $('#hid2').val();
1264 $('#search-upload').find('legend').find('span').text(legend_text);
1265 $('#select-method-tooltip').hide();
1267 else {
1268 $('#payment-allocate').hide();
1269 $('#search-btn').hide();
1270 var legend_text = $('#hid3').val();
1271 $('#search-upload').find('legend').find('span').text(legend_text);
1272 $('#select-method-tooltip').show();
1276 <?php
1277 if ($alertmsg) {
1278 echo "alert('" . addslashes($alertmsg) . "');\n";
1282 $(document).ready(function () {
1283 //using jquery-ui-1-12-1 tooltip instead of bootstrap tooltip
1284 $('#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();
1286 </script>
1287 <?php
1288 $tr_str = xl('Search');
1289 if ($_REQUEST['form_search'] == "$tr_str") { ?>
1290 <script>
1291 $("#payment-allocate").insertAfter("#search-upload");
1292 $('#payment-allocate').show();
1293 $("#search-results").show();
1294 $("#statement-download").show();
1295 </script>
1296 <?php
1299 <?php
1300 $tr_str = xl('Upload');
1301 if ($_REQUEST['form_search'] == "$tr_str") { ?>
1302 <script>
1303 $('#era-upld').show();
1304 $('#search-results').show();
1305 $("#statement-download").show();
1306 </script>
1307 <?php
1310 <script>
1311 <?php
1312 // jQuery script to change expanded/centered state dynamically
1313 require_once("../expand_contract_js.php")
1315 </script>
1317 </body>
1318 </html>