4 * The functions of this class support the billing process like the script billing_process.php.
7 * @link http://www.open-emr.org
8 * @author Eldho Chacko <eldho@zhservices.com>
9 * @author Paul Simon K <paul@zhservices.com>
10 * @author Stephen Waite <stephen.waite@cmsvt.com>
11 * @author Brady Miller <brady.g.miller@gmail.com>
12 * @copyright Copyright (c) Z&H Consultancy Services Private Limited <sam@zhservices.com>
13 * @copyright Copyright (C) 2018 Stephen Waite <stephen.waite@cmsvt.com>
14 * @copyright Copyright (c) 2019 Brady Miller <brady.g.miller@gmail.com>
15 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
19 require_once("../globals.php");
20 require_once("$srcdir/patient.inc");
21 require_once($GLOBALS['OE_SITE_DIR'] . "/statement.inc.php");
22 require_once("$srcdir/options.inc.php");
24 use OpenEMR\Billing\ParseERA
;
25 use OpenEMR\Billing\SLEOB
;
26 use OpenEMR\Common\Csrf\CsrfUtils
;
27 use OpenEMR\Core\Header
;
28 use OpenEMR\OeUI\OemrUI
;
30 $hidden_type_code = isset($_POST['hidden_type_code']) ?
$_POST['hidden_type_code'] : '';
31 $check_date = isset($_POST['check_date']) ?
$_POST['check_date'] : '';
32 $post_to_date = isset($_POST['post_to_date']) ?
$_POST['post_to_date'] : '';
33 $deposit_date = isset($_POST['deposit_date']) ?
$_POST['deposit_date'] : '';
34 $type_code = isset($_POST['type_code']) ?
$_POST['type_code'] : '';
36 //===============================================================================
37 // This is called back by ParseERA::parseERA() if we are processing X12 835's.
43 function era_callback(&$out)
45 global $where, $eracount, $eraname;
47 $eraname = $out['gs_date'] . '_' . ltrim($out['isa_control_number'], '0') .
48 '_' . ltrim($out['payer_id'], '0');
49 list($pid, $encounter, $invnumber) = SLEOB
::slInvoiceNumber($out);
50 if ($pid && $encounter) {
54 $where .= "( f.pid = '" . add_escape_custom($pid) . "' AND f.encounter = '" . add_escape_custom($encounter) . "' )";
57 //===============================================================================
58 // Handle X12 835 file upload.
59 if (!empty($_FILES['form_erafile']['size'])) {
60 if (!CsrfUtils
::verifyCsrfToken($_POST["csrf_token_form"])) {
61 CsrfUtils
::csrfNotVerified();
64 $tmp_name = $_FILES['form_erafile']['tmp_name'];
65 // Handle .zip extension if present. Probably won't work on Windows.
66 if (strtolower(substr($_FILES['form_erafile']['name'], -4)) == '.zip') {
67 rename($tmp_name, "$tmp_name.zip");
68 exec("unzip -p " . escapeshellarg($tmp_name . ".zip") . " > " . escapeshellarg($tmp_name));
69 unlink("$tmp_name.zip");
71 $alertmsg .= ParseERA
::parseERA($tmp_name, 'era_callback');
72 $erafullname = $GLOBALS['OE_SITE_DIR'] . "/documents/era/$eraname.edi";
73 if (is_file($erafullname)) {
74 $alertmsg .= xl("Warning") . ': ' . xl("Set") . ' ' . $eraname . ' ' . xl("was already uploaded") . ' ';
75 if (is_file($GLOBALS['OE_SITE_DIR'] . "/documents/era/$eraname.html")) {
77 $alertmsg .= xl("and processed.") . ' ';
79 $alertmsg .= xl("but not yet processed.") . ' ';
82 rename($tmp_name, $erafullname);
84 //===============================================================================
86 //===============================================================================
91 <?php Header
::setupHeader(['datetime-picker', 'common']);?
>
92 <?php
require_once("{$GLOBALS['srcdir']}/ajax/payment_ajax_jav.inc.php"); ?
>
96 if(document
.getElementById('uploadedfile').value
=='')
98 alert(<?php
echo xlj('Please Choose a file');?
>);
101 if(document
.getElementById('hidden_type_code').value
=='')
103 alert(<?php
echo xlj('Select Insurance, by typing'); ?
>);
104 document
.getElementById('type_code').focus();
107 if(document
.getElementById('hidden_type_code').value
!=document
.getElementById('div_insurance_or_patient').innerHTML
)
109 alert(<?php
echo xlj('Take Insurance, from Drop Down'); ?
>);
110 document
.getElementById('type_code').focus();
113 top
.restoreSession();
114 document
.forms
[0].submit();
116 function OnloadAction()
117 {//Displays message after upload action,and popups the details.
118 after_value
=document
.getElementById('after_value').value
;
124 if (!empty($_FILES['form_erafile']['size'])) {
126 var f
= document
.forms
[0];
127 var debug
= <?php
echo js_escape(($_REQUEST['form_without'] ??
null) * 1); ?
> ;
128 var paydate
= f
.check_date
.value
;
129 var post_to_date
= f
.post_to_date
.value
;
130 var deposit_date
= f
.deposit_date
.value
;
131 window
.open('sl_eob_process.php?eraname=' +
<?php
echo js_url($eraname); ?
> +
'&debug=' +
encodeURIComponent(debug
) +
'&paydate=' +
encodeURIComponent(paydate
) +
'&post_to_date=' +
encodeURIComponent(post_to_date
) +
'&deposit_date=' +
encodeURIComponent(deposit_date
) +
'&original=original' +
'&InsId=' +
<?php
echo js_url($hidden_type_code); ?
> +
'&csrf_token_form=' +
<?php
echo js_url(CsrfUtils
::collectCsrfToken()); ?
>, '_blank');
139 $
('.datepicker').datetimepicker({
140 <?php
$datetimepicker_timepicker = false; ?
>
141 <?php
$datetimepicker_showseconds = false; ?
>
142 <?php
$datetimepicker_formatInput = true; ?
>
143 <?php
require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?
>
144 <?php
// can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
149 document
.onclick
=HideTheAjaxDivs
;
152 #ajax_div_insurance {
155 background
-color
: #FBFDD0;
156 border
: 1px solid
var(--gray
);
160 border
-bottom
:1px solid
var(--black
);
163 border
-top
:1px solid
var(--black
);
166 border
-left
:1px solid
var(--black
);
169 border
-right
:1px solid
var(--black
);
171 @media only screen
and (max
-width
: 768px
) {
174 text
-align
: left
!important
;
179 @media only screen
and (max
-width
: 700px
) {
182 text
-align
: left
!important
;
185 margin
-left
: 0px
!important
;
189 .input
-group
.form
-control
{
194 margin
-left
: 5px
!important
;
198 //to determine and set the form to open in the desired state - expanded or centered, any selection the user makes will
199 //become the user-specific default for that page. collectAndOrganizeExpandSetting() contains a single array as an
200 //argument, containing one or more elements, the name of the current file is the first element, if there are linked
201 // files they should be listed thereafter, please add _xpd suffix to the file name
202 $arr_files_php = array("era_payments_xpd", "search_payments_xpd", "new_payment_xpd");
203 $current_state = collectAndOrganizeExpandSetting($arr_files_php);
204 require_once("$srcdir/expand_contract_inc.php");
206 <title
><?php
echo xlt('ERA Posting'); ?
></title
>
208 $arrOeUiSettings = array(
209 'heading_title' => xl('Payments'),
210 'include_patient_name' => false,// use only in appropriate pages
211 'expandable' => true,
212 'expandable_files' => array("era_payments_xpd", "search_payments_xpd", "new_payment_xpd"),//all file names need suffix _xpd
213 'action' => "",//conceal, reveal, search, reset, link or back
214 'action_title' => "",
215 'action_href' => "",//only for actions - reset, link or back
216 'show_help_icon' => false,
217 'help_file_name' => ""
219 $oemr_ui = new OemrUI($arrOeUiSettings);
222 <body onload
="OnloadAction()">
223 <div id
="container_div" class="<?php echo attr($oemr_ui->oeContainer());?> mt-3">
225 <div
class="col-sm-12">
226 <?php
echo $oemr_ui->pageHeading() . "\r\n"; ?
>
229 <nav
class="navbar navbar-nav navbar-expand-md navbar-light text-body bg-light mb-4 p-4">
230 <button
class="navbar-toggler icon-bar" data
-target
="#myNavbar" data
-toggle
="collapse" type
="button"> <span
class="navbar-toggler-icon"></span
></button
>
231 <div
class="collapse navbar-collapse" id
="myNavbar">
232 <ul
class="navbar-nav mr-auto">
233 <li
class="nav-item">
234 <a
class="nav-link font-weight-bold" href
='new_payment.php'><?php
echo xlt('New Payment'); ?
></a
>
236 <li
class="nav-item">
237 <a
class="nav-link font-weight-bold" href
='search_payments.php'><?php
echo xlt('Search Payment'); ?
></a
>
239 <li
class="nav-item">
240 <a
class="nav-link active font-weight-bold" href
='era_payments.php'><?php
echo xlt('ERA Posting'); ?
></a
>
246 <div
class="col-sm-12">
247 <form action
='era_payments.php' enctype
="multipart/form-data" method
='post' style
="display:inline">
248 <input type
="hidden" name
="csrf_token_form" value
="<?php echo attr(CsrfUtils::collectCsrfToken()); ?>" />
250 <div
class="jumbotron py-4">
252 <?php
echo xlt('ERA Posting'); ?
>
255 <div
class="form-group col-12 oe-file-div">
256 <div
class="input-group">
257 <label
class="input-group-prepend">
258 <span
class="btn btn-secondary">
259 <?php
echo xlt('Browse'); ?
>&hellip
;<input type
="file" id
="uploadedfile" name
="form_erafile" style
="display: none;" />
260 <input name
="MAX_FILE_SIZE" type
="hidden" value
="5000000" />
263 <input type
="text" class="form-control" placeholder
="<?php echo xla('Click Browse and select one Electronic Remittance Advice (ERA) file...'); ?>" readonly
/>
268 <div
class="form-group col-3">
269 <label
class="control-label" for="check_date"><?php
echo xlt('Date'); ?
>:</label
>
270 <input
class="form-control datepicker" id
='check_date' name
='check_date' onkeydown
="PreventIt(event)" type
='text' value
="<?php echo attr($check_date); ?>" />
272 <div
class="form-group col-3">
273 <label
class="control-label" for="post_to_date"><?php
echo xlt('Post To Date'); ?
>:</label
>
274 <input
class="form-control datepicker" id
='post_to_date' name
='post_to_date' onkeydown
="PreventIt(event)" type
='text' value
="<?php echo attr($post_to_date); ?>" />
276 <div
class="form-group col-3 clearfix">
277 <label
class="control-label" for="form_without"><?php
echo xlt('Select'); ?
>:</label
>
278 <label
class="checkbox">
279 <input name
='form_without' id
='form_without' type
='checkbox' value
='1' />
280 <span
class="oe-ckbox-label"><?php
echo xlt('Without Update'); ?
></span
>
283 <div
class="form-group col-3">
284 <label
class="control-label" for="deposit_date"><?php
echo xlt('Deposit Date'); ?
>:</label
>
285 <input
class="form-control datepicker" id
='deposit_date' name
='deposit_date' onkeydown
="PreventIt(event)" type
='text' value
="<?php echo attr($deposit_date); ?>" />
289 <div
class="form-group col-6">
290 <label
class="control-label" for="type_code"><?php
echo xlt('Insurance'); ?
>:</label
>
291 <input id
="hidden_ajax_close_value" type
="hidden" value
="<?php echo attr($type_code); ?>" />
292 <input autocomplete
="off" class="form-control" id
='type_code' name
='type_code' onkeydown
="PreventIt(event)" type
="text" value
="<?php echo attr($type_code); ?>" />
294 <!--onKeyUp
="ajaxFunction(event,'non','search_payments.php');"-->
295 <div id
='ajax_div_insurance_section'>
296 <div id
='ajax_div_insurance_error'></div
>
297 <div id
="ajax_div_insurance" style
="display:none;"></div
>
300 <div
class="form-group col-6">
301 <label
class="control-label" for="div_insurance_or_patient"><?php
echo xlt('Insurance ID'); ?
>:</label
>
302 <div
class="form-control" id
="div_insurance_or_patient" >
303 <?php
echo text($hidden_type_code); ?
>
305 <input id
="description" name
="description" type
="hidden" />
308 <!-- can change position of buttons by creating a
class 'position-override' and adding rule text
-align
:center
or right
as the
case may be in individual stylesheets
-->
309 <div
class="form-group mt-3">
310 <div
class="col-sm-12 text-left position-override">
311 <div
class="btn-group" role
="group">
312 <a
class="btn btn-primary btn-save" href
="#" onclick
="javascript:return Validate();"><?php
echo xlt('Process ERA File');?
></a
>
318 <input type
="hidden" name
="after_value" id
="after_value" value
="<?php echo attr($alertmsg); ?>" />
319 <input type
="hidden" name
="hidden_type_code" id
="hidden_type_code" value
="<?php echo attr($hidden_type_code); ?>" />
320 <input type
='hidden' name
='ajax_mode' id
='ajax_mode' value
='' />
324 </div
><!-- End of Container Div
-->
325 <?php
$oemr_ui->oeBelowContainerDiv();?
>
326 <script src
= '<?php echo $webroot;?>/library/js/oeUI/oeFileUploads.js'></script
>