3 * Billing Report Program
6 * @link http://www.open-emr.org
7 * @author Terry Hill <terry@lilysystems.com>
8 * @author Brady Miller <brady.g.miller@gmail.com>
9 * @author Jerry Padgett <sjpadgett@gmail.com>
10 * @copyright Copyright (c) 2016 Terry Hill <terry@lillysystems.com>
11 * @copyright Copyright (c) 2017-2019 Brady Miller <brady.g.miller@gmail.com>
12 * @copyright Copyright (c) 2018-2019 Jerry Padgett <sjpadgett@gmail.com>
13 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
16 require_once "../globals.php";
17 require_once "../../library/acl.inc";
18 require_once "../../custom/code_types.inc.php";
19 require_once "$srcdir/patient.inc";
20 require_once "$srcdir/../interface/reports/report.inc.php"; // Criteria Section common php page
21 require_once "$srcdir/billrep.inc";
22 require_once "$srcdir/options.inc.php";
24 use OpenEMR\Billing\BillingUtilities
;
25 use OpenEMR\Core\Header
;
26 use OpenEMR\OeUI\OemrUI
;
28 $EXPORT_INC = "$webserver_root/custom/BillingExport.php";
29 // echo $GLOBALS['daysheet_provider_totals'];
32 $daysheet_total = false;
33 $provider_run = false;
35 if ($GLOBALS['use_custom_daysheet'] != 0) {
37 if ($GLOBALS['daysheet_provider_totals'] == 1) {
38 $daysheet_total = true;
39 $provider_run = false;
41 if ($GLOBALS['daysheet_provider_totals'] == 0) {
42 $daysheet_total = false;
49 if (isset($_POST['mode'])) {
50 if (!verifyCsrfToken($_POST["csrf_token_form"])) {
54 if ($_POST['mode'] == 'export') {
55 $sql = ReturnOFXSql();
57 $results = $db->Execute($sql);
59 if ($results->RecordCount() == 0) {
60 echo "<fieldset id='error_info' style='border:1px solid #ff5d5a !Important; background-color: #ff5d5a !Important; color: #fff ! Important; font-weight: bold; font-family:sans-serif; border-radius:5px; padding:20px 5px !Important;'>";
61 echo xlt("No Bills Found to Include in OFX Export") . "<br>";
64 while (!$results->EOF
) {
65 $billings[] = $results->fields
;
68 $ofx = new OFX($billings);
69 header("Pragma: public");
71 header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
72 header("Content-Disposition: attachment; filename=openemr_ofx.ofx");
73 header("Content-Type: text/xml");
81 $from_date = isset($_POST['from_date']) ?
$_POST['from_date'] : date('Y-m-d');
82 $to_date = isset($_POST['to_date']) ?
$_POST['to_date'] : '';
83 $code_type = isset($_POST['code_type']) ?
$_POST['code_type'] : 'all';
84 $unbilled = isset($_POST['unbilled']) ?
$_POST['unbilled'] : 'on';
85 $my_authorized = isset($_POST["authorized"]) ?
$_POST["authorized"] : '';
87 // This tells us if only encounters that appear to be missing a "25" modifier
88 // are to be reported.
89 $missing_mods_only = (isset($_POST['missing_mods_only']) && !empty($_POST['missing_mods_only']));
91 $left_margin = isset($_POST["left_margin"]) ?
$_POST["left_margin"] : $GLOBALS['cms_left_margin_default'];
92 $top_margin = isset($_POST["top_margin"]) ?
$_POST["top_margin"] : $GLOBALS['cms_top_margin_default'];
94 $left_ubmargin = isset($_POST["left_ubmargin"]) ?
$_POST["left_ubmargin"] : $GLOBALS['left_ubmargin_default'];
95 $top_ubmargin = isset($_POST["top_ubmargin"]) ?
$_POST["top_ubmargin"] : $GLOBALS['top_ubmargin_default'];
97 $ofrom_date = $from_date;
99 $ocode_type = $code_type;
100 $ounbilled = $unbilled;
101 $oauthorized = $my_authorized;
102 $x = new X12Partner();
103 $partners = $x->_utility_array($x->x12_partner_factory());
109 <?php Header
::setupHeader(['datetime-picker', 'common']); ?
>
111 /*.subbtn { margin-top:3px; margin-bottom:3px; margin-left:2px; margin-right:2px }*/
112 .btn
-group
-pinch
> .btn
:nth
-last
-child(4):not(.dropdown
-toggle
) {
113 border
-top
-right
-radius
: 3px
!Important
;
114 border
-bottom
-right
-radius
: 3px
!Important
;
118 var partners
= <?php
echo json_encode($partners); ?
>;
119 function onNewPayer(oEvent
) {
120 let p
= oEvent
.target
.options
[event
.target
.selectedIndex
].dataset
.partner
;
121 let partnerSelect
= oEvent
.target
.options
[event
.target
.selectedIndex
].dataset
.partner
;
122 partnerSelect
= partnerSelect ? partnerSelect
: -1;
123 document
.getElementById("partners").value
= partnerSelect
;
126 function select_all() {
127 for ($i = 0; $i < document
.update_form
.length
; $i++
) {
128 $name = document
.update_form
[$i].name
;
129 if ($name.substring(0, 7) == "claims[" && $name.substring($name.length
-
131 document
.update_form
[$i].checked
= true;
137 function set_button_states() {
138 var f
= document
.update_form
;
139 var count0
= 0; // selected and not billed or queued
140 var count1
= 0; // selected and queued
141 var count2
= 0; // selected and billed
142 for ($i = 0; $i < f
.length
; ++
$i) {
144 if ($name.substring(0, 7) == "claims[" && $name.substring($name.length
-
145 6) == "[bill]" && f
[$i].checked
== true) {
146 if (f
[$i].value
== '0') ++count0
;
147 else if (f
[$i].value
== '1' || f
[$i].value
== '5') ++count1
;
151 var can_generate
= (count0
> 0 || count1
> 0 || count2
> 0);
152 var can_mark
= (count1
> 0 || count0
> 0 || count2
> 0);
153 var can_bill
= (count0
== 0 && count1
== 0 && count2
> 0);
154 <?php
if (file_exists($EXPORT_INC)) { ?
>
155 f
.bn_external
.disabled
= !can_generate
;
157 f
.bn_x12_support
.disabled
= !can_generate
;
158 <?php
if ($GLOBALS['support_encounter_claims']) { ?
>
159 f
.bn_x12_encounter
.disabled
= !can_generate
;
161 f
.bn_process_hcfa_support
.disabled
= !can_generate
;
162 <?php
if ($GLOBALS['preprinted_cms_1500']) { ?
>
163 f
.bn_process_hcfa_form
.disabled
= !can_generate
;
165 <?php
if ($GLOBALS['ub04_support']) { ?
>
166 f
.bn_process_ub04_support
.disabled
= !can_generate
;
168 f
.bn_hcfa_txt_file
.disabled
= !can_generate
;
169 f
.bn_reopen
.disabled
= !can_bill
;
171 f
.bn_mark
.disabled
= !can_mark
;
174 // Process a click to go to an encounter.
175 function toencounter(pid
, pubpid
, pname
, enc
, datestr
, dobstr
) {
176 top
.restoreSession();
177 encurl
= 'patient_file/encounter/encounter_top.php?set_encounter=' +
encodeURIComponent(enc
) +
178 '&pid=' +
encodeURIComponent(pid
);
179 parent
.left_nav
.setPatient(pname
, pid
, pubpid
, '', dobstr
);
180 <?php
if ($GLOBALS['new_tabs_layout']) { ?
>
181 parent
.left_nav
.setEncounter(datestr
, enc
, 'enc');
182 parent
.left_nav
.loadFrame('enc2', 'enc', encurl
);
184 var othername
= (window
.name
== 'RTop') ?
'RBot' : 'RTop';
185 parent
.left_nav
.setEncounter(datestr
, enc
, othername
);
186 parent
.frames
[othername
].location
.href
= '../' + encurl
;
190 // Process a click to go to an patient.
191 function topatient(pid
, pubpid
, pname
, enc
, datestr
, dobstr
) {
192 top
.restoreSession();
193 paturl
= 'patient_file/summary/demographics_full.php?pid=' +
encodeURIComponent(pid
);
194 parent
.left_nav
.setPatient(pname
, pid
, pubpid
, '', dobstr
);
195 <?php
if ($GLOBALS['new_tabs_layout']) { ?
>
196 parent
.left_nav
.loadFrame('ens1', 'enc',
197 'patient_file/history/encounters.php?pid=' +
encodeURIComponent(pid
));
198 parent
.left_nav
.loadFrame('dem1', 'pat', paturl
);
200 var othername
= (window
.name
== 'RTop') ?
'RBot' : 'RTop';
201 parent
.frames
[othername
].location
.href
= '../' + paturl
;
205 function popMBO(pid
, enc
, mboid
) {
206 if (!window
.focus
) return true;
207 if (!ProcessBeforeSubmitting()) return false;
208 top
.restoreSession();
209 let qstring
= "&pid=" +
encodeURIComponent(pid
) +
"&enc=" +
encodeURIComponent(enc
) +
"&id=" +
encodeURIComponent(mboid
);
210 let href
= "<?php echo $GLOBALS['web_root']?>/interface/patient_file/encounter/view_form.php?formname=misc_billing_options&isBilling=1" + qstring
;
211 dlgopen(href
, 'mbopop', 'modal-lg', 750, false, '', {
212 sizeHeight
: 'full' // override min height auto size.
217 function popUB04(pid
, enc
) {
218 if (!window
.focus
) return true;
219 if (!ProcessBeforeSubmitting()) return false;
220 top
.restoreSession();
221 let href
= "<?php echo $GLOBALS['web_root']?>/interface/billing/ub04_form.php?pid=" +
encodeURIComponent(pid
) +
"&enc=" +
encodeURIComponent(enc
);
222 dlgopen(href
, 'ub04pop', 1175, 750, false, '', {
223 sizeHeight
: 'full' // override min height auto size.
228 var EncounterDateArray
= new Array;
229 var CalendarCategoryArray
= new Array;
230 var EncounterIdArray
= new Array;
231 var EncounterNoteArray
= new Array;
233 function SubmitTheScreen() { //Action on Update List link
234 if (!ProcessBeforeSubmitting()) return false;
235 $
("#update-tooltip").replaceWith("<i class='fa fa-refresh fa-spin fa-1x' style=\"color:red\"></i>");
236 top
.restoreSession();
237 document
.the_form
.mode
.value
= 'change';
238 document
.the_form
.target
= '_self';
239 document
.the_form
.action
= 'billing_report.php';
240 document
.the_form
.submit();
244 function SubmitTheScreenPrint() { //Action on View Printable Report link
245 if (!ProcessBeforeSubmitting()) return false;
246 top
.restoreSession();
247 document
.the_form
.target
= 'new';
248 document
.the_form
.action
= 'print_billing_report.php';
249 document
.the_form
.submit();
253 function SubmitTheEndDayPrint() { //Action on View End of Day Report link
254 if (!ProcessBeforeSubmitting()) return false;
255 top
.restoreSession();
256 document
.the_form
.target
= 'new';
257 <?php
if ($GLOBALS['use_custom_daysheet'] == 1) { ?
>
258 document
.the_form
.action
= 'print_daysheet_report_num1.php';
260 <?php
if ($GLOBALS['use_custom_daysheet'] == 2) { ?
>
261 document
.the_form
.action
= 'print_daysheet_report_num2.php';
263 <?php
if ($GLOBALS['use_custom_daysheet'] == 3) { ?
>
264 document
.the_form
.action
= 'print_daysheet_report_num3.php';
266 document
.the_form
.submit();
270 function SubmitTheScreenExportOFX() { //Action on Export OFX link
271 if (!ProcessBeforeSubmitting()) return false;
272 top
.restoreSession();
273 document
.the_form
.mode
.value
= 'export';
274 document
.the_form
.target
= '_self';
275 document
.the_form
.action
= 'billing_report.php';
276 document
.the_form
.submit();
280 function TestExpandCollapse() { //Checks whether the Expand All, Collapse All labels need to be placed.If any result set is there these will be placed.
282 for (i
= 1; i
<= document
.getElementById("divnos").value
; i++
) {
283 var ele
= document
.getElementById("divid_" + i
);
290 if (document
.getElementById("ExpandAll")) {
291 document
.getElementById("ExpandAll").innerHTML
= '';
292 document
.getElementById("CollapseAll").innerHTML
= '';
297 function expandcollapse(atr
) {
298 if (atr
== "expand") { //Called in the Expand All, Collapse All links(All items will be expanded or collapsed)
299 for (i
= 1; i
<= document
.getElementById("divnos").value
; i++
) {
300 var mydivid
= "divid_" + i
;
301 var myspanid
= "spanid_" + i
;
302 var ele
= document
.getElementById(mydivid
);
303 var text
= document
.getElementById(myspanid
);
305 ele
.style
.display
= "inline";
307 "<?php echo xla('Collapse'); ?>";
311 for (i
= 1; i
<= document
.getElementById("divnos").value
; i++
) {
312 var mydivid
= "divid_" + i
;
313 var myspanid
= "spanid_" + i
;
314 var ele
= document
.getElementById(mydivid
);
315 var text
= document
.getElementById(myspanid
);
317 ele
.style
.display
= "none";
319 <?php
echo xlj('Expand'); ?
>;
325 function divtoggle(spanid
, divid
) { //Called in the Expand, Collapse links(This is for a single item)
326 var ele
= document
.getElementById(divid
);
328 var text
= document
.getElementById(spanid
);
329 if (ele
.style
.display
== "inline") {
330 ele
.style
.display
= "none";
332 <?php
echo xlj('Expand'); ?
>;
334 ele
.style
.display
= "inline";
336 <?php
echo xlj('Collapse'); ?
>;
341 function MarkAsCleared(Type
) {
342 CheckBoxBillingCount
= 0;
343 for (var CheckBoxBillingIndex
= 0; ; CheckBoxBillingIndex++
) {
344 CheckBoxBillingObject
= document
.getElementById('CheckBoxBilling' +
345 CheckBoxBillingIndex
);
346 if (!CheckBoxBillingObject
) break;
347 if (CheckBoxBillingObject
.checked
) {
348 ++CheckBoxBillingCount
;
352 Message
= <?php
echo xlj('After saving your batch, click[View Log] to check for errors.'); ?
>;
355 Message
= <?php
echo xlj('After saving the PDF, click[View Log] to check for errors.'); ?
>;
358 Message
= <?php
echo xlj('After saving the TEXT file(s), click[View Log] to check for errors.'); ?
>;
360 if (confirm(Message +
"\n\n\n" +
<?php
echo xlj('Total'); ?
> +
' ' +
361 CheckBoxBillingCount +
' ' +
362 <?php
echo xlj('Selected'); ?
> +
"\n" +
363 <?php
echo xlj('Would You Like them to be Marked as Cleared.'); ?
> +
"\n" +
364 <?php
echo xlj('Click OK to Clear or Cancel to continue processing.'); ?
>
366 document
.getElementById('HiddenMarkAsCleared').value
= 'yes';
368 document
.getElementById('HiddenMarkAsCleared').value
= '';
372 <?php
require_once "$srcdir/../interface/reports/report.script.php"; ?
>
373 <!-- Criteria Section common javascript page
-->
374 <!-- =============Included
for Insurance ajax criteria
==== -->
375 <?php
require_once "{$GLOBALS['srcdir']}/ajax/payment_ajax_jav.inc.php"; ?
>
377 #ajax_div_insurance {
380 background
-color
: #FBFDD0;
381 border
: 1px solid
#ccc;
384 button
[type
="submit"].subbtn
-warning
{
385 background
: #ec971f !important;
386 color
: black
!important
;
388 button
[type
="submit"].subbtn
-warning
:hover
{
389 background
: #da8104 !important;
390 color
: #fff !important;
392 @media only screen
and (max
-width
: 1024px
) {
395 text
-align
: left
!Important
;
401 @media
(min
-width
: 992px
) {
403 width
: 1000px
!Important
;
406 .table th
, .table td
{
407 border
-top
: none
!important
;
410 font
-family
: "FontAwesome"
415 a
, a
:visited
, a
:hover
{
416 text
-decoration
: none
;
421 document
.onclick
= TakeActionOnHide
;
423 <!-- =============Included
for Insurance ajax criteria
==== -->
424 <title
><?php
echo xlt('Billing Manager'); ?
></title
>
426 $arrOeUiSettings = array(
427 'heading_title' => xl('Billing Manager'),
428 'include_patient_name' => false,// use only in appropriate pages
429 'expandable' => true,
430 'expandable_files' => array('billing_report_xpd'),//all file names need suffix _xpd
431 'action' => "conceal",//conceal, reveal, search, reset, link or back
432 'action_title' => "",
433 'action_href' => "",//only for actions - reset, link or back
434 'show_help_icon' => false,
435 'help_file_name' => ""
437 $oemr_ui = new OemrUI($arrOeUiSettings);
440 <body
class="body_top" onLoad
="TestExpandCollapse()">
441 <div id
="container_div" class="<?php echo attr($oemr_ui->oeContainer()); ?>">
443 <div
class="col-sm-12">
444 <div
class="page-header">
446 <?php
echo xlt('Billing Manager') ?
> <i id
="exp_cont_icon" class="fa <?php echo attr($expand_icon_class);?> oe-superscript-small expand_contract"
447 title
="<?php echo attr($expand_title); ?>" aria
-hidden
="true"></i
> <i id
="show_hide" class="fa fa-eye-slash fa-2x small"
448 title
="<?php echo xla('Click to Hide'); ?>"></i
>
450 <?php
echo $oemr_ui->pageHeading() . "\r\n"; ?
>
455 <div
class="col-sm-12">
456 <form name
='the_form' method
='post' action
='billing_report.php' onsubmit
='return top.restoreSession()' style
="display:inline">
457 <input type
="hidden" name
="csrf_token_form" value
="<?php echo attr(collectCsrfToken()); ?>" />
458 <input type
='hidden' name
='mode' value
='change'>
459 <div
class="col-xs-9">
460 <!-- ============================================================================================================================================= -->
461 <!-- Criteria section Starts
-->
462 <!-- ============================================================================================================================================= -->
464 // The following are the search criteria per page.All the following variable which ends with 'Master' need to be filled properly.
465 // Each item is seperated by a comma(,).
466 // $ThisPageSearchCriteriaDisplayMaster ==>It is the display on screen for the set of criteria.
467 // $ThisPageSearchCriteriaKeyMaster ==>Corresponding database fields in the same order.
468 // $ThisPageSearchCriteriaDataTypeMaster ==>Corresponding data type in the same order.
469 $ThisPageSearchCriteriaDisplayRadioMaster = array();
470 $ThisPageSearchCriteriaRadioKeyMaster = array();
471 $ThisPageSearchCriteriaQueryDropDownMaster = array();
472 $ThisPageSearchCriteriaQueryDropDownMasterDefault = array();
473 $ThisPageSearchCriteriaQueryDropDownMasterDefaultKey = array();
474 $ThisPageSearchCriteriaIncludeMaster = array();
477 $ThisPageSearchCriteriaDisplayMaster = array(
478 xl("Date of Service"),
480 xl("Date of Billing"),
484 xl("Insurance Company"),
486 xl("Whether Insured"),
488 xl("Billing Status"),
489 xl("Authorization Status"),
490 xl("Last Level Billed"),
494 $ThisPageSearchCriteriaKeyMaster = "form_encounter.date,billing.date,claims.process_time,claims.target,patient_data.fname," . "form_encounter.pid,claims.payer_id,form_encounter.encounter,insurance_data.provider,billing.id,billing.billed," . "billing.authorized,form_encounter.last_level_billed,billing.x12_partner_id,billing.user";
495 $ThisPageSearchCriteriaDataTypeMaster = "datetime,datetime,datetime,radio,text_like," . "text,include,text,radio,radio,radio," . "radio_like,radio,query_drop_down,text";
497 $ThisPageSearchCriteriaDisplayMaster = array(
498 xl("Date of Service"),
500 xl("Date of Billing"),
504 xl("Insurance Company"),
506 xl("Whether Insured"),
508 xl("Billing Status"),
509 xl("Authorization Status"),
510 xl("Last Level Billed"),
513 $ThisPageSearchCriteriaKeyMaster = "form_encounter.date,billing.date,claims.process_time,claims.target,patient_data.fname," . "form_encounter.pid,claims.payer_id,form_encounter.encounter,insurance_data.provider,billing.id,billing.billed," . "billing.authorized,form_encounter.last_level_billed,billing.x12_partner_id";
514 $ThisPageSearchCriteriaDataTypeMaster = "datetime,datetime,datetime,radio,text_like," . "text,include,text,radio,radio,radio," . "radio_like,radio,query_drop_down";
516 // The below section is needed if there is any 'radio' or 'radio_like' type in the $ThisPageSearchCriteriaDataTypeMaster
517 // $ThisPageSearchCriteriaDisplayRadioMaster,$ThisPageSearchCriteriaRadioKeyMaster ==>For each radio data type this pair comes.
518 // The key value 'all' indicates that no action need to be taken based on this.For that the key must be 'all'.Display value can be any thing.
519 $ThisPageSearchCriteriaDisplayRadioMaster[1] = array(
524 $ThisPageSearchCriteriaRadioKeyMaster[1] = "all,standard,hcfa"; // Key
525 $ThisPageSearchCriteriaDisplayRadioMaster[2] = array(
530 $ThisPageSearchCriteriaRadioKeyMaster[2] = "all,1,0"; // Key
531 $ThisPageSearchCriteriaDisplayRadioMaster[3] = array(
536 $ThisPageSearchCriteriaRadioKeyMaster[3] = "all,not null,null"; // Key
537 $ThisPageSearchCriteriaDisplayRadioMaster[4] = array(
543 $ThisPageSearchCriteriaRadioKeyMaster[4] = "all,0,1,7"; // Key
544 $ThisPageSearchCriteriaDisplayRadioMaster[5] = array(
549 $ThisPageSearchCriteriaRadioKeyMaster[5] = "%,1,0";
550 $ThisPageSearchCriteriaDisplayRadioMaster[6] = array(
556 $ThisPageSearchCriteriaRadioKeyMaster[6] = "all,0,1,2";
557 // The below section is needed if there is any 'query_drop_down' type in the $ThisPageSearchCriteriaDataTypeMaster
558 $ThisPageSearchCriteriaQueryDropDownMaster[1] = "SELECT name,id FROM x12_partners;";
559 $ThisPageSearchCriteriaQueryDropDownMasterDefault[1] = xl("All"); // Only one item will be here
560 $ThisPageSearchCriteriaQueryDropDownMasterDefaultKey[1] = "all"; // Only one item will be here
561 // The below section is needed if there is any 'include' type in the $ThisPageSearchCriteriaDataTypeMaster
562 // Function name is added here.Corresponding include files need to be included in the respective pages as done in this page.
563 // It is labled(Included for Insurance ajax criteria)(Line:-279-299).
564 $ThisPageSearchCriteriaIncludeMaster[1] = "InsuranceCompanyDisplay"; // This is php function defined in the file 'report.inc.php'
566 if (!isset($_REQUEST['mode'])) {// default case
567 $_REQUEST['final_this_page_criteria'][0] = "(form_encounter.date between '" . date("Y-m-d 00:00:00") . "' and '" . date("Y-m-d 23:59:59") . "')";
568 $_REQUEST['final_this_page_criteria'][1] = "billing.billed = '0'";
569 $_REQUEST['final_this_page_criteria_text'][0] = xl("Date of Service = Today");
570 $_REQUEST['final_this_page_criteria_text'][1] = xl("Billing Status = Unbilled");
571 $_REQUEST['date_master_criteria_form_encounter_date'] = "today";
572 $_REQUEST['master_from_date_form_encounter_date'] = date("Y-m-d");
573 $_REQUEST['master_to_date_form_encounter_date'] = date("Y-m-d");
574 $_REQUEST['radio_billing_billed'] = 0;
577 <div
class="hideaway">
578 <?php
require_once "$srcdir/../interface/reports/criteria.tab.php"; ?
>
581 // ============================================================================================================================================= -->
582 // Criteria section Ends -->
583 // ============================================================================================================================================= -->
587 <div
class="form-group col-xs-3 hideaway">
589 <legend
><?php
echo xlt('Select Action'); ?
></legend
>
590 <div
class="form-group col-xs-12">
593 <li
><a
class="link_submit" href
="#"
594 onclick
="javascript:return SubmitTheScreen();"><strong
><?php
echo xlt('Update List') ?
></strong
>
595 </a
><i id
='update-tooltip' class="fa fa-info-circle text-primary" aria
-hidden
="true"></i
></li
>
596 <li
><a
class='link_submit' href
="#"
597 onclick
="javascript:return SubmitTheScreenExportOFX();"><strong
><?php
echo xlt('Export OFX'); ?
></strong
></a
>
599 <li
><a
class='link_submit' href
="#" onclick
="javascript:return SubmitTheScreenPrint();"><strong
><?php
echo xlt('View Printable Report'); ?
></strong
></a
>
602 <?php
if ($daysheet) { ?
>
603 <li
><a
class='link_submit' href
="#"
604 onclick
="javascript:return SubmitTheEndDayPrint();"><strong
><?php
echo xlt('End Of Day Report') . ' - ' ?
></strong
></a
>
605 <?php
if ($daysheet_total) { ?
>
606 <span
class="text"><strong
><?php
echo xlt('Totals'); ?
></strong
></span
>
607 <input name
="end_of_day_totals_only" type
="checkbox" value
="1"></li
>
609 <?php
if ($provider_run) { ?
>
610 <span
class="text"><strong
><?php
echo xlt('Provider'); ?
></strong
></span
>
611 <input name
="end_of_day_provider_only" type
="checkbox" value
="1"></li
>
615 <?php
if (!file_exists($EXPORT_INC)) { ?
>
616 <li
><a href
='#' id
="view-log-link" data
-toggle
="modal" data
-target
="#myModal" class='link_submit'
617 title
='<?php echo xla('See messages from the last set of generated claims
'); ?>'><strong
><?php
echo xlt('View Log'); ?
></strong
></a
>
620 <li
><a
class="link_submit"
621 href
="JavaScript:void(0);" onclick
="select_all(); return false;"><strong
><?php
echo xlt('Select All'); ?
></strong
></a
>
633 <div
class="col-sm-12">
634 <form
class="form-inline" name
='update_form' method
='post' action
='billing_process.php' onsubmit
='return top.restoreSession()' style
="display:inline">
635 <input type
="hidden" name
="csrf_token_form" value
="<?php echo attr(collectCsrfToken()); ?>" />
636 <?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 ?>
637 <div
class="form-group clearfix">
638 <div
class="btn-group btn-group-pinch position-override" role
="group">
639 <div
class="btn-group">
640 <button type
="button" class="btn btn-default dropdown-toggle" data
-toggle
="dropdown"
641 name
="bn_x12_support"
642 title
="<?php echo xla('A claim must be selected to enable this menu.') ?>"><?php
echo xla('X12 OPTIONS') ?
>
643 <span
class="caret"></span
></button
>
644 <ul
class="dropdown-menu" role
="menu">
645 <?php
if (file_exists($EXPORT_INC)) { ?
>
647 <button type
="submit" data
-open
-popup
="true" class="btn btn-default btn-download"
649 title
="<?php echo xla('Export to external billing system') ?>"
650 value
="<?php echo xla("Export Billing
") ?>"><?php
echo xlt("Export Billing") ?
></button
>
653 <button type
="submit" data
-open
-popup
="true" class="btn btn-default btn-download"
655 title
="<?php echo xla('Mark as billed but skip billing') ?>"><?php
echo xlt("Mark as Cleared") ?
></button
>
659 <button type
="submit" class="btn btn-default btn-download" name
="bn_x12"
660 onclick
="MarkAsCleared(1)"
661 title
="<?php echo xla('Generate and download X12 batch') ?>"><?php
echo xlt('Generate X12') ?
></button
>
664 <?php
if ($GLOBALS['ub04_support']) { ?
>
666 <button type
="submit" class="btn btn-default btn-download" name
="bn_ub04_x12"
667 title
="<?php echo xla('Generate Institutional X12 837I') ?>"><?php
echo xlt('Generate X12 837I') ?
></button
>
670 <?php
if ($GLOBALS['support_encounter_claims']) { ?
>
672 <button type
="submit" class="btn btn-default btn-download" name
="bn_x12_encounter"
673 onclick
="MarkAsCleared(1)"
674 title
="<?php echo xla('Generate and download X12 encounter claim batch') ?>"><?php
echo xlt('Generate X12 Encounter') ?
></button
>
679 <div
class="btn-group">
680 <button type
="button" class="btn btn-default dropdown-toggle" data
-toggle
="dropdown"
681 name
="bn_process_hcfa_support"
682 title
="<?php echo xla('A claim must be selected to enable this menu.') ?>"><?php
echo xlt('HCFA FORM') ?
>
683 <span
class="caret"></span
></button
>
684 <ul
class="dropdown-menu" role
="menu">
686 <button type
="submit" class="btn btn-default btn-download" name
="bn_process_hcfa"
687 onclick
="MarkAsCleared(2)"
688 title
="<?php echo xla('Generate and download CMS 1500 paper claims') ?>"><?php
echo xlt('CMS 1500 PDF') ?
></button
>
690 <?php
if ($GLOBALS['preprinted_cms_1500']) { ?
>
692 <button type
="submit" class="btn btn-default btn-download"
693 name
="bn_process_hcfa_form" onclick
="MarkAsCleared(2)"
694 title
="<?php echo xla('Generate and download CMS 1500 paper claims on Preprinted form') ?>"><?php
echo xlt('CMS 1500 incl FORM') ?
></button
>
698 <button type
="submit" class="btn btn-default btn-download" name
="bn_hcfa_txt_file"
699 onclick
="MarkAsCleared(3)"
700 title
="<?php echo xla('Making batch text files for uploading to Clearing House and will mark as billed') ?>"><?php
echo xlt('CMS 1500 TEXT') ?
></button
>
704 <?php
if ($GLOBALS['ub04_support']) { ?
>
705 <div
class="btn-group">
706 <button type
="button" class="btn btn-default dropdown-toggle" data
-toggle
="dropdown"
707 name
="bn_process_ub04_support"
708 title
="<?php echo xla('A claim must be selected to enable this menu.') ?>"><?php
echo xlt('UB04 FORM') ?
>
709 <span
class="caret"></span
></button
>
710 <ul
class="dropdown-menu" role
="menu">
712 <button type
="submit" class="btn btn-default btn-download"
713 name
="bn_process_ub04_form"
714 title
="<?php echo xla('Generate and download UB-04 CMS1450 with form') ?>"><?php
echo xlt('UB04 FORM PDF') ?
></button
>
717 <button type
="submit" class="btn btn-default btn-download" name
="bn_process_ub04"
718 title
="<?php echo xla('Generate and download UB-04 CMS1450') ?>"><?php
echo xlt('UB04 TEXT PDF') ?
></button
>
723 <button
class="btn btn-default btn-download" data
-open
-popup
="true" name
="bn_mark"
724 title
="<?php echo xla('Post to accounting and mark as billed') ?>"
725 type
="submit"><?php
echo xla('Mark as Cleared') ?
></button
>
726 <button
class="btn btn-default btn-undo" data
-open
-popup
="true" name
="bn_reopen"
727 title
="<?php echo xla('Mark as not billed') ?>"
728 type
="submit"><?php
echo xlt('Re-Open') ?
></button
>
730 <div
class="input-group">
731 <label
for="left_margin"><?php
echo xlt('CMS 1500 Margins Left'); ?
>:</label
>
732 <input type
='text' size
='2' id
='left_margin' name
='left_margin'
733 value
='<?php echo attr($left_margin); ?>'
734 title
='<?php echo xla('HCFA left margin in points
'); ?>'/>
735 <label
for="top_margin"><?php
echo xlt('Top'); ?
>:</label
>
736 <input type
='text' size
='2' id
='top_margin' name
='top_margin'
737 value
='<?php echo attr($top_margin); ?>'
738 title
='<?php echo xla('HCFA top margin in points
'); ?>'/>
740 <?php
if ($ub04_support) { ?
>
741 <div
class="input-group">
742 <label
for="left_ubmargin"><?php
echo xlt('UB04 Margins Left'); ?
>:</label
>
743 <input type
='text' size
='2' id
='left_ubmargin' name
='left_ubmargin'
744 value
='<?php echo attr($left_ubmargin); ?>'
745 title
='<?php echo xla('UB04 left margin in points
'); ?>'/>
746 <label
for="top_ubmargin"><?php
echo xlt('Top'); ?
>:</label
>
747 <input type
='text' size
='2' id
='top_ubmargin' name
='top_ubmargin'
748 value
='<?php echo attr($top_ubmargin); ?>'
749 title
='<?php echo xla('UB04 top margin in points
'); ?>'/>
753 <input id
='HiddenMarkAsCleared' name
='HiddenMarkAsCleared' type
='hidden' value
="">
754 <input name
='mode' type
='hidden' value
="bill">
755 <input name
='authorized' type
='hidden' value
="<?php echo attr($my_authorized); ?>">
756 <input name
='unbilled' type
='hidden' value
="<?php echo attr($unbilled); ?>">
757 <input name
='code_type' type
='hidden' value
="%">
758 <input name
='to_date' type
='hidden' value
="<?php echo attr($to_date); ?>">
759 <input name
='from_date' type
='hidden' value
="<?php echo attr($from_date); ?>">
761 if ($my_authorized == "on") {
762 $my_authorized = "1";
764 $my_authorized = "%";
766 if ($unbilled == "on") {
771 $list = getBillsListBetween("%");
774 if (!isset($_POST["mode"])) {
775 if (!isset($_POST["from_date"])) {
776 $from_date = date("Y-m-d");
778 $from_date = $_POST["from_date"];
780 if (empty($_POST["to_date"])) {
783 $to_date = $_POST["to_date"];
785 if (!isset($_POST["code_type"])) {
788 $code_type = $_POST["code_type"];
790 if (!isset($_POST["unbilled"])) {
793 $unbilled = $_POST["unbilled"];
795 if (!isset($_POST["authorized"])) {
796 $my_authorized = "on";
798 $my_authorized = $_POST["authorized"];
801 $from_date = $_POST["from_date"];
802 $to_date = $_POST["to_date"];
803 $code_type = $_POST["code_type"];
804 $unbilled = $_POST["unbilled"];
805 $my_authorized = $_POST["authorized"];
808 if ($my_authorized == "on") {
809 $my_authorized = "1";
811 $my_authorized = "%";
814 if ($unbilled == "on") {
820 if (isset($_POST["mode"]) && $_POST["mode"] == "bill") {
821 billCodesList($list);
824 <div
class="table-responsive">
825 <table
class="table table-condensed">
828 if ($ret = getBillsBetween("%")) {
829 if (is_array($ret)) {
832 <td colspan
='9' align
="right">
833 <table width
="250" border
="0" cellspacing
="0" cellpadding
="0">
835 <td width
="100" id
='ExpandAll'><a
836 onclick
="expandcollapse('expand');" class='small'
837 href
="JavaScript:void(0);"><?php
echo '(' . xlt('Expand All') . ')' ?
></a
>
839 <td width
="100" id
='CollapseAll'><a
840 onclick
="expandcollapse('collapse');" class='small'
841 href
="JavaScript:void(0);"><?php
echo '(' . xlt('Collapse All') . ')' ?
></a
>
843 <td width
="50"> 
;</td
>
852 $last_encounter_id = "";
860 $mmo_empty_mod = false;
861 $mmo_num_charges = 0;
863 foreach ($ret as $iter) {
864 // We include encounters here that have never been billed. However
865 // if it had no selected billing items but does have non-selected
866 // billing items, then it is not of interest.
869 "SELECT count(*) AS count FROM billing WHERE " .
870 "encounter = ? AND " .
874 $iter['enc_encounter'],
878 if ($res['count'] > 0) {
883 $this_encounter_id = $iter['enc_pid'] . "-" . $iter['enc_encounter'];
885 if ($last_encounter_id != $this_encounter_id) {
886 // This dumps all HTML for the previous encounter.
889 while ($rcount < $lcount) {
890 $rhtml .= "<tr bgcolor='" . attr($bgcolor) . "'><td colspan='9'></td></tr>";
893 // This test handles the case where we are only listing encounters
894 // that appear to have a missing "25" modifier.
895 if (!$missing_mods_only ||
($mmo_empty_mod && $mmo_num_charges > 1)) {
896 if ($DivPut == 'yes') {
900 echo "<tr bgcolor='" . attr($bgcolor) . "'>\n<td rowspan='" . attr($rcount) . "' valign='top'>\n$lhtml</td>$rhtml\n";
901 echo "<tr bgcolor='" . attr($bgcolor) . "'><td colspan='9' height='5'></td></tr>\n\n";
908 $mmo_empty_mod = false;
909 $mmo_num_charges = 0;
911 // If there are ANY unauthorized items in this encounter and this is
912 // the normal case of viewing only authorized billing, then skip the
916 if ($my_authorized == '1') {
918 "SELECT count(*) AS count FROM billing WHERE " .
919 "encounter = ? AND " .
921 "activity = 1 AND authorized = 0",
923 $iter['enc_encounter'],
927 if ($res['count'] > 0) {
929 $last_encounter_id = $this_encounter_id;
935 $mboid = sqlQuery("SELECT forms.form_id FROM forms WHERE forms.encounter = ? AND forms.authorized = 1 AND forms.formdir = 'misc_billing_options' AND forms.deleted != 1 LIMIT 1", array($iter['enc_encounter']));
936 $iter['mboid'] = $mboid ?
attr($mboid['form_id']) : 0;
938 $name = getPatientData($iter['enc_pid'], "fname, mname, lname, pubpid, billing_note, DATE_FORMAT(DOB,'%Y-%m-%d') as DOB_YMD");
940 // Check if patient has primary insurance and a subscriber exists for it.
941 // If not we will highlight their name in red.
942 // TBD: more checking here.
945 "SELECT count(*) AS count FROM insurance_data WHERE " .
947 "type='primary' AND " .
948 "subscriber_lname IS NOT NULL AND " .
949 "subscriber_lname != '' LIMIT 1",
954 $namecolor = ($res['count'] > 0) ?
"black" : "#ff7777";
956 $bgcolor = "#" . (($encount & 1) ?
"FFFAEF" : "F8F8FF");
957 echo "<tr bgcolor='" . attr($bgcolor) . "'><td colspan='9' height='5'></td></tr>\n";
962 $ptname = $name['fname'] . " " . $name['lname'];
963 $raw_encounter_date = date("Y-m-d", strtotime($iter['enc_date']));
964 $billing_note = $name['billing_note'];
965 // Add Encounter Date to display with "To Encounter" button 2/17/09 JCH
966 $lhtml .= "<span class=bold><font color='" . attr($namecolor) . "'>" . text($ptname) . "</font></span><span class=small> (" . text($iter['enc_pid']) . "-" . text($iter['enc_encounter']) . ")</span>";
968 // Encounter details are stored to javacript as array.
969 $result4 = sqlStatement(
970 "SELECT fe.encounter,fe.date,fe.billing_note,openemr_postcalendar_categories.pc_catname FROM form_encounter AS fe " .
971 " LEFT JOIN openemr_postcalendar_categories ON fe.pc_catid=openemr_postcalendar_categories.pc_catid WHERE fe.pid = ? ORDER BY fe.date DESC",
976 if (sqlNumRows($result4) > 0) {
981 EncounterDateArray
[<?php
echo attr($iter['enc_pid']); ?
>] = new Array;
982 CalendarCategoryArray
[<?php
echo attr($iter['enc_pid']); ?
>] = new Array;
983 EncounterIdArray
[<?php
echo attr($iter['enc_pid']); ?
>] = new Array;
984 EncounterNoteArray
[<?php
echo attr($iter['enc_pid']); ?
>] = new Array;
986 while ($rowresult4 = sqlFetchArray($result4)) {
988 EncounterIdArray
[<?php
echo attr($iter['enc_pid']); ?
>][Count
] = <?php
echo js_escape($rowresult4['encounter']); ?
>;
989 EncounterDateArray
[<?php
echo attr($iter['enc_pid']); ?
>][Count
] = <?php
echo js_escape(oeFormatShortDate(date("Y-m-d", strtotime($rowresult4['date'])))); ?
>;
990 CalendarCategoryArray
[<?php
echo attr($iter['enc_pid']); ?
>][Count
] = <?php
echo js_escape(xl_appt_category($rowresult4['pc_catname'])); ?
>;
991 EncounterNoteArray
[<?php
echo attr($iter['enc_pid']); ?
>][Count
] = <?php
echo js_escape($rowresult4['billing_note']); ?
>;
994 $enc_billing_note = $rowresult4['billing_note'];
999 $lhtml .= "<div class='button-group'>";
1000 // Not sure why the next section seems to do nothing except post "To Encounter" button 2/17/09 JCH
1001 $lhtml .= "<a class=\"btn btn-xs btn-default\" role=\"button\" " . "href=\"javascript:
1002 window.toencounter(" . attr_js($iter['enc_pid']) . "," . attr_js($name['pubpid']) . "," . attr_js($ptname) . "," . attr_js($iter['enc_encounter']) . "," . attr_js(oeFormatShortDate($raw_encounter_date)) . "," . attr_js(" ".xl('DOB').": ".oeFormatShortDate($name['DOB_YMD'])." ".xl('Age').": ".getPatientAge($name['DOB_YMD'])) . ");
1003 top.window.parent.left_nav.setPatientEncounter(EncounterIdArray[" . attr($iter['enc_pid']) . "],EncounterDateArray[" . attr($iter['enc_pid']) . "], CalendarCategoryArray[" . attr($iter['enc_pid']) . "]);
1004 if (top.tab_mode) { top.setEncounter(" . attr_js($iter['enc_encounter']) . "); }
1005 \">" . xlt('Encounter') . " " . text(oeFormatShortDate($raw_encounter_date)) . "</a>";
1007 // Changed "To xxx" buttons to allow room for encounter date display 2/17/09 JCH
1008 $lhtml .= "<a class=\"btn btn-xs btn-default\" role=\"button\" " . "href=\"javascript:window.topatient(" . attr_js($iter['enc_pid']) . "," . attr_js($name['pubpid']) . "," . attr_js($ptname) . "," . attr_js($iter['enc_encounter']) . "," . attr_js(oeFormatShortDate($raw_encounter_date)) . "," . attr_js(" ".xl('DOB').": ".oeFormatShortDate($name['DOB_YMD'])." ".xl('Age').": ".getPatientAge($name['DOB_YMD'])) . ");
1009 top.window.parent.left_nav.setPatientEncounter(EncounterIdArray[" . attr($iter['enc_pid']) . "],EncounterDateArray[" . attr($iter['enc_pid']) . "], CalendarCategoryArray[" . attr($iter['enc_pid']) . "])\">" . xlt('Patient') . "</a>";
1010 $is_edited = $iter['mboid'] ?
'btn-success' : 'btn-default';
1011 $title = $iter['mboid'] ?
xlt("This claim has HCFA 1500 miscellaneous billing options") : xlt("Click to add HCFA 1500 miscellaneous billing options");
1012 $lhtml .= "<a class='btn btn-xs $is_edited' role='button' title='" . attr($title) . "' onclick='popMBO(" . attr_js($iter['enc_pid']) . "," . attr_js($iter['enc_encounter']) . "," . attr_js($iter['mboid']) . "); return false;'>" . xlt('MBO ') . "</a>";
1013 if ($ub04_support && isset($iter['billed'])) {
1015 "SELECT submitted_claim AS status FROM claims WHERE " .
1016 "encounter_id = ? AND " .
1018 "ORDER BY version DESC LIMIT 1",
1020 $iter['enc_encounter'],
1024 $is_edited = $c['status'] ?
'btn-success' : 'btn-warning';
1025 $bname = $c['status'] ?
xl('Reviewed') : xl('Review UB04');
1026 $lhtml .= "<a class='btn btn-xs $is_edited' role='button' onclick='popUB04(" . attr_js($iter['enc_pid']) . "," . attr_js($iter['enc_encounter']) . "); return false;'>" . text($bname) . "</a>";
1029 $divnos = $divnos +
1;
1030 $lhtml .= " <a onclick='divtoggle(" . attr_js("spanid_".$divnos) . "," . attr_js("divid_".$divnos) . ");' class='small' id='aid_" . attr($divnos) . "' href=\"JavaScript:void(0);" . "\">(<span id=spanid_" . attr($divnos) . " class=\"indicator\">" . xlt('Expand') . '</span>)<br></a>';
1031 if ($GLOBALS['notes_to_display_in_Billing'] == 2 ||
$GLOBALS['notes_to_display_in_Billing'] == 3) {
1032 $lhtml .= '<span style="margin-left: 20px; font-weight: bold; color: red">' . text($billing_note) . '</span>';
1037 $lhtml .= "<br />\n";
1038 $lhtml .= " <span class='form-group'>" . xlt('Bill') . ": ";
1039 $lhtml .= "<select name='claims[" . attr($this_encounter_id) . "][payer]' onchange='onNewPayer(event)' style='background-color:" . attr($bgcolor) . "'>";
1041 $query = "SELECT id.provider AS id, id.type, id.date, " .
1042 "ic.x12_default_partner_id AS ic_x12id, ic.name AS provider " .
1043 "FROM insurance_data AS id, insurance_companies AS ic WHERE " .
1044 "ic.id = id.provider AND " .
1047 "ORDER BY id.type ASC, id.date DESC";
1049 $result = sqlStatement(
1057 $default_x12_partner = $iter['ic_x12id'];
1060 while ($row = sqlFetchArray($result)) {
1061 if (strcmp($row['type'], $prevtype) == 0) {
1064 $prevtype = $row['type'];
1065 if (strlen($row['provider']) > 0) {
1066 // This preserves any existing insurance company selection, which is
1067 // important when EOB posting has re-queued for secondary billing.
1068 $lhtml .= "<option value=\"" . attr(substr($row['type'], 0, 1) . $row['id']) . "\"";
1069 if (($count == 0 && !$iter['payer_id']) ||
$row['id'] == $iter['payer_id']) {
1070 $lhtml .= " selected";
1071 if (!is_numeric($default_x12_partner)) {
1072 $default_x12_partner = $row['ic_x12id'];
1075 $lhtml .= " data-partner='" . attr($row['ic_x12id']) . "'>" . text($row['type']) . ": " . text($row['provider']) . "</option>";
1080 $lhtml .= "<option value='-1'>" . xlt("Unassigned") . "</option>\n";
1081 $lhtml .= "</select> \n";
1082 $lhtml .= " <span class='form-group'>X12: ";
1083 $lhtml .= "<select id='partners' name='claims[" . attr($this_encounter_id) . "][partner]' style='margin-top:5px; background-color:" . attr($bgcolor) . "'>";
1084 $lhtml .= "<option value='-1' label='Unassigned'>" . xlt("Partner not configured") . "</option>\n";
1085 foreach ($partners as $xid => $xname) {
1086 if (empty(trim($xname))) {
1089 $lhtml .= '<option label="' . attr($xname) . '" value="' . attr($xid) . '"';
1090 if ($xid == $default_x12_partner) {
1091 $lhtml .= "selected";
1093 $lhtml .= '>' . text($xname) . '</option>';
1095 $lhtml .= "</select></span>";
1098 if ($GLOBALS['notes_to_display_in_Billing'] == 1 ||
$GLOBALS['notes_to_display_in_Billing'] == 3) {
1099 $lhtml .= "<br><span style='margin-left: 20px; font-weight: bold; color: green'>" . text($enc_billing_note) . "</span>";
1101 $lhtml .= "<br>\n <div id='divid_" . attr($divnos) . "' style='display:none'>" . text(oeFormatShortDate(substr($iter['date'], 0, 10))) . text(substr($iter['date'], 10, 6)) . " " . xlt("Encounter was coded");
1103 $query = "SELECT * FROM claims WHERE patient_id = ? AND encounter_id = ? ORDER BY version";
1104 $cres = sqlStatement(
1108 $iter['enc_encounter']
1114 while ($crow = sqlFetchArray($cres)) {
1115 $query = "SELECT id.type, ic.name " .
1116 "FROM insurance_data AS id, insurance_companies AS ic WHERE " .
1118 "id.provider = ? AND " .
1119 "id.date <= ? AND " .
1120 "ic.id = id.provider " .
1121 "ORDER BY id.type ASC, id.date DESC";
1132 if ($crow['bill_process']) {
1133 $lhtml .= "<br>\n " . text(oeFormatShortDate(substr($crow['bill_time'], 0, 10))) . text(substr($crow['bill_time'], 10, 6)) . " " . xlt("Queued for") . " " . text($irow['type']) . " " . text($crow['target']) . " " . xlt("billing to ") . text($irow['name']);
1135 } elseif ($crow['status'] < 6) {
1136 if ($crow['status'] > 1) {
1137 $lhtml .= "<br>\n " . text(oeFormatShortDate(substr($crow['bill_time'], 0, 10))) . text(substr($crow['bill_time'], 10, 6)) . " " . xlt("Marked as cleared");
1140 $lhtml .= "<br>\n " . text(oeFormatShortDate(substr($crow['bill_time'], 0, 10))) . text(substr($crow['bill_time'], 10, 6)) . " " . xlt("Re-opened");
1143 } elseif ($crow['status'] == 6) {
1144 $lhtml .= "<br>\n " . text(oeFormatShortDate(substr($crow['bill_time'], 0, 10))) . text(substr($crow['bill_time'], 10, 6)) . " " . xlt("This claim has been forwarded to next level.");
1146 } elseif ($crow['status'] == 7) {
1147 $lhtml .= "<br>\n " . text(oeFormatShortDate(substr($crow['bill_time'], 0, 10))) . text(substr($crow['bill_time'], 10, 6)) . " " . xlt("This claim has been denied.Reason:-");
1148 if ($crow['process_file']) {
1149 $code_array = explode(',', $crow['process_file']);
1150 foreach ($code_array as $code_key => $code_value) {
1151 $lhtml .= "<br>\n ";
1152 $reason_array = explode('_', $code_value);
1153 if (!isset($adjustment_reasons[$reason_array[3]])) {
1154 $lhtml .= xlt("For code") . ' [' . text($reason_array[0]) . '] ' . xlt("and modifier") . ' [' . text($reason_array[1]) . '] ' . xlt("the Denial code is") . ' [' . text($reason_array[2]) . ' ' . text($reason_array[3]) . ']';
1156 $lhtml .= xlt("For code") . ' [' . text($reason_array[0]) . '] ' . xlt("and modifier") . ' [' . text($reason_array[1]) . '] ' . xlt("the Denial Group code is") . ' [' . text($reason_array[2]) . '] ' . xlt("and the Reason is") . ':- ' . text($adjustment_reasons[$reason_array[3]]);
1160 $lhtml .= xlt("Not Specified.");
1165 if ($crow['process_time']) {
1166 $lhtml .= "<br>\n " . text(oeFormatShortDate(substr($crow['process_time'], 0, 10))) . text(substr($crow['process_time'], 10, 6)) . " " . xlt("Claim was generated to file") . " " . "<a href='get_claim_file.php?key=" . attr_url($crow['process_file']) . "&csrf_token_form=" . attr_url(collectCsrfToken()) . "' onclick='top.restoreSession()'>" . text($crow['process_file']) . "</a>";
1171 } // end while ($crow = sqlFetchArray($cres))
1173 if ($lastcrow && $lastcrow['status'] == 4) {
1174 $lhtml .= "<br>\n " . xlt("This claim has been closed.");
1178 if ($lastcrow && $lastcrow['status'] == 5) {
1179 $lhtml .= "<br>\n " . xlt("This claim has been canceled.");
1182 } // end if ($iter['id'])
1183 } // end if ($last_encounter_id != $this_encounter_id)
1189 // Collect info related to the missing modifiers test.
1190 if ($iter['fee'] > 0) {
1192 $tmp = substr($iter['code'], 0, 3);
1193 if (($tmp == '992' ||
$tmp == '993') && empty($iter['modifier'])) {
1194 $mmo_empty_mod = true;
1201 $rhtml .= "<tr bgcolor='$bgcolor'>\n";
1203 $rhtml .= "<td width='50'>";
1204 if ($iter['id'] && $oldcode != $iter['code_type']) {
1205 $rhtml .= "<span class=text>" . text($iter['code_type']) . ": </span>";
1208 $oldcode = $iter['code_type'];
1209 $rhtml .= "</td>\n";
1212 if ($iter['id'] && $code_types[$iter['code_type']]['just']) {
1213 $js = explode(":", $iter['justify']);
1215 foreach ($js as $j) {
1217 if ($counter == 0) {
1218 $justify .= " (<b>" . text($j) . "</b>)";
1220 $justify .= " (" . text($j) . ")";
1227 $rhtml .= "<td><span class='text'>" . ($iter['code_type'] == 'COPAY' ?
text(oeFormatMoney($iter['code'])) : text($iter['code']));
1228 if ($iter['modifier']) {
1229 $rhtml .= ":" . text($iter['modifier']);
1231 $rhtml .= "</span><span style='font-size:8pt;'>$justify</span></td>\n";
1233 $rhtml .= '<td align="right"><span style="font-size:8pt;"> ';
1234 if ($iter['id'] && $iter['fee'] > 0) {
1235 $rhtml .= text(oeFormatMoney($iter['fee']));
1237 $rhtml .= "</span></td>\n";
1238 $rhtml .= '<td><span style="font-size:8pt;"> ';
1240 $rhtml .= getProviderName(empty($iter['provider_id']) ?
text($iter['enc_provider_id']) : text($iter['provider_id']));
1242 $rhtml .= "</span></td>\n";
1243 $rhtml .= '<td><span style="font-size:8pt;"> ';
1244 if ($GLOBALS['display_units_in_billing'] != 0) {
1246 $rhtml .= xlt("Units") . ":" . text($iter{"units"});
1249 $rhtml .= "</span></td>\n";
1250 $rhtml .= '<td width=100> <span style="font-size:8pt;">';
1252 $rhtml .= text(oeFormatSDFT(strtotime($iter{"date"})));
1254 $rhtml .= "</span></td>\n";
1255 // This error message is generated if the authorized check box is not checked
1256 if ($iter['id'] && $iter['authorized'] != 1) {
1257 $rhtml .= "<td><span class=alert>" . xlt("Note: This code has not been authorized.") . "</span></td>\n";
1259 $rhtml .= "<td></td>\n";
1261 if ($iter['id'] && $last_encounter_id != $this_encounter_id) {
1262 $tmpbpr = $iter['bill_process'];
1263 if ($tmpbpr == '0' && $iter['billed']) {
1266 $rhtml .= "<td><input type='checkbox' value='" . attr($tmpbpr) . "' name='claims[" . attr($this_encounter_id) . "][bill]' onclick='set_button_states()' id='CheckBoxBilling" . attr($CheckBoxBilling * 1) . "'> </td>\n";
1269 $rhtml .= "<td></td>\n";
1271 if ($last_encounter_id != $this_encounter_id) {
1274 $resMoneyGot = sqlStatement(
1275 "SELECT pay_amount AS PatientPay,date(post_time) AS date FROM ar_activity WHERE " .
1276 "pid = ? AND encounter = ? AND payer_type=0 AND account_code='PCP'",
1279 $iter['enc_encounter']
1282 // new fees screen copay gives account_code='PCP'
1283 if (sqlNumRows($resMoneyGot) > 0) {
1287 // checks whether a copay exists for the encounter and if exists displays it.
1288 while ($rowMoneyGot = sqlFetchArray($resMoneyGot)) {
1290 $PatientPay = $rowMoneyGot['PatientPay'];
1291 $date = $rowMoneyGot['date'];
1292 if ($PatientPay > 0) {
1294 $rhtml2 .= "<tr bgcolor='$bgcolor'>\n";
1296 $rhtml2 .= "<td width='50'>";
1297 $rhtml2 .= "<span class='text'>" . xlt('COPAY') . ": </span>";
1298 $rhtml2 .= "</td>\n";
1299 $rhtml2 .= "<td><span class='text'>" . text(oeFormatMoney($PatientPay)) . "</span><span style='font-size:8pt;'> </span></td>\n";
1300 $rhtml2 .= '<td align="right"><span style="font-size:8pt;"> ';
1301 $rhtml2 .= "</span></td>\n";
1302 $rhtml2 .= '<td><span style="font-size:8pt;"> ';
1303 $rhtml2 .= "</span></td>\n";
1304 $rhtml2 .= '<td><span style="font-size:8pt;"> ';
1305 $rhtml2 .= "</span></td>\n";
1306 $rhtml2 .= '<td width=100> <span style="font-size:8pt;">';
1307 $rhtml2 .= text(oeFormatSDFT(strtotime($date)));
1308 $rhtml2 .= "</span></td>\n";
1309 if ($iter['id'] && $iter['authorized'] != 1) {
1310 $rhtml2 .= "<td><span class=alert>" . xlt("Note: This copay was entered against billing that has not been authorized. Please review status.") . "</span></td>\n";
1312 $rhtml2 .= "<td></td>\n";
1314 if (!$iter['id'] && $rowcnt == 1) {
1315 $rhtml2 .= "<td><input type='checkbox' value='0' name='claims[" . attr($this_encounter_id) . "][bill]' onclick='set_button_states()' id='CheckBoxBilling" . attr($CheckBoxBilling * 1) . "'> </td>\n";
1318 $rhtml2 .= "<td></td>\n";
1324 $rhtml .= "</tr>\n";
1325 $last_encounter_id = $this_encounter_id;
1329 while ($rcount < $lcount) {
1330 $rhtml .= "<tr bgcolor='" . attr($bgcolor) . "'><td colspan='9'></td></tr>";
1333 if (!$missing_mods_only ||
($mmo_empty_mod && $mmo_num_charges > 1)) {
1334 if ($DivPut == 'yes') {
1338 echo "<tr bgcolor='" . attr($bgcolor) . "'>\n<td rowspan='" . attr($rcount) . "' valign='top' width='25%'>\n$lhtml</td>$rhtml\n";
1339 echo "<tr bgcolor='" . attr($bgcolor) . "'><td colspan='9' height='5'></td></tr>\n";
1350 </div
><!--end of container div
-->
1351 <?php
$oemr_ui->oeBelowContainerDiv();?
>
1353 set_button_states();
1356 echo "alert(" . js_escape($alertmsg) . ");\n";
1360 $
("#view-log-link").click( function() {
1361 top
.restoreSession();
1362 dlgopen('customize_log.php', '_blank', 500, 400);
1365 $
('button[type="submit"]').click(function () {
1366 top
.restoreSession();
1367 $
(this
).attr('data-clicked', true);
1370 $
('form[name="update_form"]').submit(function (e
) {
1371 var clickedButton
= $
("button[type=submit][data-clicked='true'")[0];
1372 // clear clicked button indicator
1373 $
('button[type="submit"]').attr('data-clicked', false);
1375 if (!clickedButton || $
(clickedButton
).attr("data-open-popup") !== "true") {
1376 $
(this
).removeAttr("target");
1377 return top
.restoreSession();
1379 top
.restoreSession();
1380 var w
= window
.open('about:blank', 'Popup_Window', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=400,height=300,left = 312,top = 234');
1381 this
.target
= 'Popup_Window';
1385 $
('.datepicker').datetimepicker({
1386 <?php
$datetimepicker_timepicker = false; ?
>
1387 <?php
$datetimepicker_showseconds = false; ?
>
1388 <?php
$datetimepicker_formatInput = false; ?
>
1389 <?php
require $GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'; ?
>
1390 <?php
// can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
1392 // jquery-ui tooltip converted to bootstrap tooltip
1393 $
('#update-tooltip').attr("title", <?php
echo xlj('Click Update List to display billing information filtered by the selected Current Criteria'); ?
>).tooltip();
1397 <input type
="hidden" name
="divnos" id
="divnos" value
="<?php echo attr($divnos) ?>"/>
1398 <input type
='hidden' name
='ajax_mode' id
='ajax_mode' value
=''/>