make active default setting for care_team_status (#4565)
[openemr.git] / interface / billing / era_payments.php
blob139e534c58050d4ed32490573f5a49062ca19ce1
1 <?php
3 /*
4 * The functions of this class support the billing process like the script billing_process.php.
6 * @package OpenEMR
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.
38 $alertmsg = '';
39 $where = '';
40 $eraname = '';
41 $eracount = 0;
42 $Processed = 0;
43 function era_callback(&$out)
45 global $where, $eracount, $eraname;
46 ++$eracount;
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) {
51 if ($where) {
52 $where .= ' OR ';
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")) {
76 $Processed = 1;
77 $alertmsg .= xl("and processed.") . ' ';
78 } else {
79 $alertmsg .= xl("but not yet processed.") . ' ';
82 rename($tmp_name, $erafullname);
83 } // End 835 upload
84 //===============================================================================
86 //===============================================================================
88 <!DOCTYPE html>
89 <html>
90 <head>
91 <?php Header::setupHeader(['datetime-picker', 'common']);?>
92 <?php require_once("{$GLOBALS['srcdir']}/ajax/payment_ajax_jav.inc.php"); ?>
93 <script>
94 function Validate()
96 if(document.getElementById('uploadedfile').value=='')
98 alert(<?php echo xlj('Please Choose a file');?>);
99 return false;
101 if(document.getElementById('hidden_type_code').value=='')
103 alert(<?php echo xlj('Select Insurance, by typing'); ?>);
104 document.getElementById('type_code').focus();
105 return false;
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();
111 return false;
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;
119 if(after_value!='')
121 alert(after_value);
123 <?php
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');
132 return false;
133 <?php
138 $(function () {
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 ?>
147 </script>
148 <script>
149 document.onclick=HideTheAjaxDivs;
150 </script>
151 <style>
152 #ajax_div_insurance {
153 position: absolute;
154 z-index: 10;
155 background-color: #FBFDD0;
156 border: 1px solid var(--gray);
157 padding: 10px;
159 .bottom {
160 border-bottom:1px solid var(--black);
162 .top {
163 border-top:1px solid var(--black);
165 .left {
166 border-left:1px solid var(--black);
168 .right {
169 border-right:1px solid var(--black);
171 @media only screen and (max-width: 768px) {
172 [class*="col-"] {
173 width: 100%;
174 text-align: left !important;
179 @media only screen and (max-width: 700px) {
180 [class*="col-"] {
181 width: 100%;
182 text-align: left !important;
184 #form_without {
185 margin-left: 0px !important;
189 .input-group .form-control {
190 margin-bottom: 3px;
191 margin-left: 0px;
193 #form_without {
194 margin-left: 5px !important;
196 </style>
197 <?php
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>
207 <?php
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);
221 </head>
222 <body onload="OnloadAction()">
223 <div id="container_div" class="<?php echo attr($oemr_ui->oeContainer());?> mt-3">
224 <div class="row">
225 <div class="col-sm-12">
226 <?php echo $oemr_ui->pageHeading() . "\r\n"; ?>
227 </div>
228 </div>
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>
235 </li>
236 <li class="nav-item">
237 <a class="nav-link font-weight-bold" href='search_payments.php'><?php echo xlt('Search Payment'); ?></a>
238 </li>
239 <li class="nav-item">
240 <a class="nav-link active font-weight-bold" href='era_payments.php'><?php echo xlt('ERA Posting'); ?></a>
241 </li>
242 </ul>
243 </div>
244 </nav>
245 <div class="row">
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()); ?>" />
249 <fieldset>
250 <div class="jumbotron py-4">
251 <div class="row h3">
252 <?php echo xlt('ERA Posting'); ?>
253 </div>
254 <div class="row">
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" />
261 </span>
262 </label>
263 <input type="text" class="form-control" placeholder="<?php echo xla('Click Browse and select one Electronic Remittance Advice (ERA) file...'); ?>" readonly />
264 </div>
265 </div>
266 </div>
267 <div class="row">
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); ?>" />
271 </div>
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); ?>" />
275 </div>
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>
281 </label>
282 </div>
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); ?>" />
286 </div>
287 </div>
288 <div class="row">
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); ?>" />
293 <br />
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>
298 </div>
299 </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); ?>
304 </div>
305 <input id="description" name="description" type="hidden" />
306 </div>
307 </div>
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>
313 </div>
314 </div>
315 </div>
316 </div>
317 </fieldset>
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='' />
321 </form>
322 </div>
323 </div>
324 </div><!-- End of Container Div-->
325 <?php $oemr_ui->oeBelowContainerDiv();?>
326 <script src = '<?php echo $webroot;?>/library/js/oeUI/oeFileUploads.js'></script>
327 </body>
328 </html>