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