2 // +-----------------------------------------------------------------------------+
3 // Copyright (C) 2010 Z&H Consultancy Services Private Limited <sam@zhservices.com>
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
18 // A copy of the GNU General Public License is included along with this program:
19 // openemr/interface/login/GnuGPL.html
20 // For more information write to the Free Software
21 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 // Author: Eldho Chacko <eldho@zhservices.com>
24 // Paul Simon K <paul@zhservices.com>
26 // +------------------------------------------------------------------------------+
27 //===============================================================================
28 //Electronic posting is handled here.
29 //===============================================================================
32 require_once("../globals.php");
33 require_once("$srcdir/patient.inc");
34 require_once("$srcdir/invoice_summary.inc.php");
35 require_once($GLOBALS['OE_SITE_DIR'] . "/statement.inc.php");
36 require_once("$srcdir/parse_era.inc.php");
37 require_once("$srcdir/sl_eob.inc.php");
39 use OpenEMR\Core\Header
;
41 $hidden_type_code = isset($_POST['hidden_type_code']) ?
$_POST['hidden_type_code'] : '';
42 $check_date = isset($_POST['check_date']) ?
$_POST['check_date'] : '';
43 $post_to_date = isset($_POST['post_to_date']) ?
$_POST['post_to_date'] : '';
44 $deposit_date = isset($_POST['deposit_date']) ?
$_POST['deposit_date'] : '';
45 $type_code = isset($_POST['type_code']) ?
$_POST['type_code'] : '';
47 //===============================================================================
48 // This is called back by parse_era() if we are processing X12 835's.
54 function era_callback(&$out)
56 global $where, $eracount, $eraname;
58 $eraname = $out['gs_date'] . '_' . ltrim($out['isa_control_number'], '0') .
59 '_' . ltrim($out['payer_id'], '0');
60 list($pid, $encounter, $invnumber) = slInvoiceNumber($out);
61 if ($pid && $encounter) {
65 $where .= "( f.pid = '" . add_escape_custom($pid) . "' AND f.encounter = '" . add_escape_custom($encounter) . "' )";
68 //===============================================================================
69 // Handle X12 835 file upload.
70 if ($_FILES['form_erafile']['size']) {
71 if (!verifyCsrfToken($_POST["csrf_token_form"])) {
72 die(xlt('Authentication Error'));
75 $tmp_name = $_FILES['form_erafile']['tmp_name'];
76 // Handle .zip extension if present. Probably won't work on Windows.
77 if (strtolower(substr($_FILES['form_erafile']['name'], -4)) == '.zip') {
78 rename($tmp_name, "$tmp_name.zip");
79 exec("unzip -p " . escapeshellarg($tmp_name.".zip") . " > " . escapeshellarg($tmp_name));
80 unlink("$tmp_name.zip");
82 $alertmsg .= parse_era($tmp_name, 'era_callback');
83 $erafullname = $GLOBALS['OE_SITE_DIR'] . "/era/$eraname.edi";
84 if (is_file($erafullname)) {
85 $alertmsg .= xl("Warning").': '. xl("Set").' '.$eraname.' '. xl("was already uploaded").' ';
86 if (is_file($GLOBALS['OE_SITE_DIR'] . "/era/$eraname.html")) {
88 $alertmsg .= xl("and processed.").' ';
90 $alertmsg .= xl("but not yet processed.").' ';
93 rename($tmp_name, $erafullname);
95 //===============================================================================
97 //===============================================================================
102 <?php Header
::setupHeader(['datetime-picker', 'common']);?
>
103 <?php
require_once("{$GLOBALS['srcdir']}/ajax/payment_ajax_jav.inc.php"); ?
>
104 <script language
="javascript" type
="text/javascript">
107 if(document
.getElementById('uploadedfile').value
=='')
109 alert("<?php echo xls('Please Choose a file');?>");
112 if(document
.getElementById('hidden_type_code').value
=='')
114 alert("<?php echo xls('Select Insurance, by typing'); ?>");
115 document
.getElementById('type_code').focus();
118 if(document
.getElementById('hidden_type_code').value
!=document
.getElementById('div_insurance_or_patient').innerHTML
)
120 alert("<?php echo xls('Take Insurance, from Drop Down'); ?>");
121 document
.getElementById('type_code').focus();
124 top
.restoreSession();
125 document
.forms
[0].submit();
127 function OnloadAction()
128 {//Displays message after upload action,and popups the details.
129 after_value
=document
.getElementById('after_value').value
;
135 if ($_FILES['form_erafile']['size']) {
137 var f
= document
.forms
[0];
138 var debug
= <?php
echo attr($_REQUEST['form_without']*1); ?
> ;
139 var paydate
= f
.check_date
.value
;
140 var post_to_date
= f
.post_to_date
.value
;
141 var deposit_date
= f
.deposit_date
.value
;
142 window
.open('sl_eob_process.php?eraname=<?php echo attr(urlencode($eraname)); ?>&debug=' + debug +
'&paydate=' + paydate +
'&post_to_date=' + post_to_date +
'&deposit_date=' + deposit_date +
'&original=original' +
'&InsId=<?php echo attr(urlencode($hidden_type_code)); ?>' +
'&csrf_token_form=<?php echo attr(urlencode(collectCsrfToken())); ?>' , '_blank');
149 $
(document
).ready(function() {
150 $
('.datepicker').datetimepicker({
151 <?php
$datetimepicker_timepicker = false; ?
>
152 <?php
$datetimepicker_showseconds = false; ?
>
153 <?php
$datetimepicker_formatInput = true; ?
>
154 <?php
require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?
>
155 <?php
// can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
159 <script language
="javascript" type
="text/javascript">
160 document
.onclick
=HideTheAjaxDivs
;
163 #ajax_div_insurance {
166 background
-color
: #FBFDD0;
167 border
: 1px solid
#ccc;
170 .bottom
{border
-bottom
:1px solid black
;}
171 .top
{border
-top
:1px solid black
;}
172 .left
{border
-left
:1px solid black
;}
173 .right
{border
-right
:1px solid black
;}
174 @media only screen
and (max
-width
: 768px
) {
177 text
-align
: left
!Important
;
179 .navbar
-toggle
>span
.icon
-bar
{
180 background
-color
: #68171A ! Important;
182 .navbar
-default .navbar
-toggle
{
183 border
-color
: #4a4a4a;
185 .navbar
-default .navbar
-toggle
:focus
, .navbar
-default .navbar
-toggle
:hover
{
186 background
-color
: #f2f2f2 !Important;
187 font
-weight
: 900 !Important
;
188 color
: #000000 !Important;
191 background
-color
: #E5E5E5;
194 background
-color
: #68171A;
201 background
-color
: #f2f2f2;
204 float: none
!important
;
209 .navbar
-collapse
.collapse
.in
{
211 background
-color
: #dfdfdf;
213 color
: #000000 !Important;
218 @media only screen
and (max
-width
: 700px
) {
221 text
-align
:left
!Important
;
224 margin
-left
:0px
!Important
;
228 .input
-group
.form
-control
{
233 margin
-left
:5px
!Important
;
236 <title
><?php
echo xlt('ERA Posting'); ?
></title
>
238 <body
class="body_top" onload
="OnloadAction()">
239 <div
class="container">
241 <div
class="page-header">
242 <h2
><?php
echo xlt('Payments'); ?
></h2
>
246 <nav
class="navbar navbar-default navbar-color navbar-static-top" >
247 <div
class="container-fluid">
248 <div
class="navbar-header">
249 <button
class="navbar-toggle" data
-target
="#myNavbar" data
-toggle
="collapse" type
="button"><span
class="icon-bar"></span
> <span
class="icon-bar"></span
> <span
class="icon-bar"></span
></button
>
251 <div
class="collapse navbar-collapse" id
="myNavbar" >
252 <ul
class="nav navbar-nav" >
253 <li
class="oe-bold-black">
254 <a href
='new_payment.php' style
="font-weight:700; color:#000000"><?php
echo xlt('New Payment'); ?
></a
>
256 <li
class="oe-bold-black" >
257 <a href
='search_payments.php' style
="font-weight:700; color:#000000"><?php
echo xlt('Search Payment'); ?
></a
>
260 <a href
='era_payments.php' style
="font-weight:700; color:#000000"><?php
echo xlt('ERA Posting'); ?
></a
>
269 <form action
='era_payments.php' enctype
="multipart/form-data" method
='post' style
="display:inline">
270 <input type
="hidden" name
="csrf_token_form" value
="<?php echo attr(collectCsrfToken()); ?>" />
272 <div
class="col-xs-12 oe-custom-line">
273 <div
class="form-group col-xs9 oe-file-div">
274 <div
class="input-group">
275 <label
class="input-group-btn">
276 <span
class="btn btn-default">
277 <?php
echo xlt('Browse'); ?
>&hellip
;<input type
="file" id
="uploadedfile" name
="form_erafile" style
="display: none;" >
278 <input name
="MAX_FILE_SIZE" type
="hidden" value
="5000000">
281 <input type
="text" class="form-control" placeholder
="<?php echo xla('Click Browse and select one Electronic Remittance Advice (ERA) file...'); ?>" readonly
>
285 <div
class="col-xs-12 oe-custom-line">
286 <div
class="form-group col-xs-3">
287 <label
class="control-label" for="check_date"><?php
echo xlt('Date'); ?
>:</label
>
288 <input
class="form-control datepicker" id
='check_date' name
='check_date' onkeydown
="PreventIt(event)" type
='text' value
="<?php echo attr($check_date); ?>">
290 <div
class="form-group col-xs-3">
291 <label
class="control-label" for="post_to_date"><?php
echo xlt('Post To Date'); ?
>:</label
>
292 <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); ?>">
294 <div
class="form-group col-xs-3 clearfix">
295 <label
class="control-label" for="form_without"><?php
echo xlt('Select'); ?
>:</label
>
296 <label
class="checkbox">
297 <input name
='form_without' id
='form_without' type
='checkbox' value
='1'> <span
class="oe-ckbox-label"><?php
echo xlt('Without Update'); ?
></span
>
300 <div
class="form-group col-xs-3">
301 <label
class="control-label" for="deposit_date"><?php
echo xlt('Deposit Date'); ?
>:</label
>
302 <input
class="form-control datepicker" id
='deposit_date' name
='deposit_date' onkeydown
="PreventIt(event)" type
='text' value
="<?php echo attr($deposit_date); ?>">
305 <div
class="col-xs-12 oe-custom-line">
306 <div
class="form-group col-xs-6">
307 <label
class="control-label" for="type_code"><?php
echo xlt('Insurance'); ?
>:</label
>
308 <input id
="hidden_ajax_close_value" type
="hidden" value
="<?php echo attr($type_code); ?>">
309 <input autocomplete
="off" class="form-control" id
='type_code' name
='type_code' onkeydown
="PreventIt(event)" type
="text" value
="<?php echo attr($type_code); ?>"><br
>
310 <!--onKeyUp
="ajaxFunction(event,'non','search_payments.php');"-->
311 <div id
='ajax_div_insurance_section'>
312 <div id
='ajax_div_insurance_error'></div
>
313 <div id
="ajax_div_insurance" style
="display:none;"></div
>
316 <div
class="form-group col-xs-3">
317 <label
class="control-label" for="div_insurance_or_patient"><?php
echo xlt('Insurance ID'); ?
>:</label
>
318 <div
class="form-control" id
="div_insurance_or_patient" >
319 <?php
echo text($hidden_type_code); ?
>
321 <input id
="description" name
="description" type
="hidden">
325 <?php
//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 ?>
326 <div
class="form-group clearfix">
327 <div
class="col-sm-12 text-left position-override">
328 <div
class="btn-group" role
="group">
329 <a
class="btn btn-default btn-save" href
="#" onclick
="javascript:return Validate();"><span
><?php
echo xlt('Process ERA File');?
></span
></a
>
333 <input type
="hidden" name
="after_value" id
="after_value" value
="<?php echo attr($alertmsg); ?>"/>
334 <input type
="hidden" name
="hidden_type_code" id
="hidden_type_code" value
="<?php echo attr($hidden_type_code); ?>"/>
335 <input type
='hidden' name
='ajax_mode' id
='ajax_mode' value
='' />
338 </div
><!-- End of Container Div
-->
341 //https://www.abeautifulsite.net/whipping-file-inputs-into-shape-with-bootstrap-3
342 // We can attach the `fileselect` event to all file inputs on the page
343 $
(document
).on('change', ':file', function() {
345 numFiles
= input
.get(0).files ? input
.get(0).files
.length
: 1,
346 label
= input
.val().replace(/\\/g
, '/').replace(/.*\
//, '');
347 input
.trigger('fileselect', [numFiles
, label
]);
350 // We can watch for our custom `fileselect` event like this
351 $
(document
).ready( function() {
352 $
(':file').on('fileselect', function(event
, numFiles
, label
) {
353 var input
= $
(this
).parents('.input-group').find(':text'),
354 log
= numFiles
> 1 ? numFiles +
' files selected' : label
;
360 if( log
) alert(log
);