Highway to PSR2
[openemr.git] / interface / billing / era_payments.php
blobea88b02c809e52b8d1c31cbc69306f7aeae13537
1 <?php
2 // +-----------------------------------------------------------------------------+
3 // Copyright (C) 2010 Z&H Consultancy Services Private Limited <sam@zhservices.com>
4 //
5 //
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 //===============================================================================
30 require_once("../globals.php");
31 require_once("$srcdir/patient.inc");
32 require_once("$srcdir/invoice_summary.inc.php");
33 require_once($GLOBALS['OE_SITE_DIR'] . "/statement.inc.php");
34 require_once("$srcdir/parse_era.inc.php");
35 require_once("$srcdir/sl_eob.inc.php");
36 //===============================================================================
37 // This is called back by parse_era() 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) = slInvoiceNumber($out);
50 if ($pid && $encounter) {
51 if ($where) {
52 $where .= ' OR ';
55 $where .= "( f.pid = '$pid' AND f.encounter = '$encounter' )";
58 //===============================================================================
59 // Handle X12 835 file upload.
60 if ($_FILES['form_erafile']['size']) {
61 $tmp_name = $_FILES['form_erafile']['tmp_name'];
62 // Handle .zip extension if present. Probably won't work on Windows.
63 if (strtolower(substr($_FILES['form_erafile']['name'], -4)) == '.zip') {
64 rename($tmp_name, "$tmp_name.zip");
65 exec("unzip -p $tmp_name.zip > $tmp_name");
66 unlink("$tmp_name.zip");
69 $alertmsg .= parse_era($tmp_name, 'era_callback');
70 $erafullname = $GLOBALS['OE_SITE_DIR'] . "/era/$eraname.edi";
71 if (is_file($erafullname)) {
72 $alertmsg .= xl("Warning").': '. xl("Set").' '.$eraname.' '. xl("was already uploaded").' ';
73 if (is_file($GLOBALS['OE_SITE_DIR'] . "/era/$eraname.html")) {
74 $Processed=1;
75 $alertmsg .= xl("and processed.").' ';
76 } else {
77 $alertmsg .= xl("but not yet processed.").' ';
83 rename($tmp_name, $erafullname);
84 } // End 835 upload
85 //===============================================================================
87 //===============================================================================
89 <html>
90 <head>
91 <?php if (function_exists('html_header_show')) {
92 html_header_show();
93 } ?>
94 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
95 <link rel="stylesheet" type="text/css" href="../../library/js/fancybox/jquery.fancybox-1.2.6.css" media="screen" />
96 <link rel="stylesheet" href="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.min.css">
98 <script type="text/javascript" src="../../library/textformat.js?v=<?php echo $v_js_includes; ?>"></script>
99 <script type="text/javascript" src="../../library/dialog.js?v=<?php echo $v_js_includes; ?>"></script>
100 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-7-2/index.js"></script>
101 <?php include_once("{$GLOBALS['srcdir']}/ajax/payment_ajax_jav.inc.php"); ?>
102 <script type="text/javascript" src="../../library/js/common.js?v=<?php echo $v_js_includes; ?>"></script>
103 <script type="text/javascript" src="../../library/js/fancybox/jquery.fancybox-1.2.6.js"></script>
104 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.full.min.js"></script>
106 <script language='JavaScript'>
107 var mypcc = '1';
108 </script>
109 <script type="text/javascript" language="javascript" >
110 function Validate()
112 if(document.getElementById('uploadedfile').value=='')
114 alert("<?php echo htmlspecialchars(xl('Please Choose a file'), ENT_QUOTES) ?>");
115 return false;
117 if(document.getElementById('hidden_type_code').value=='')
119 alert("<?php echo htmlspecialchars(xl('Select Insurance, by typing'), ENT_QUOTES) ?>");
120 document.getElementById('type_code').focus();
121 return false;
123 if(document.getElementById('hidden_type_code').value!=document.getElementById('div_insurance_or_patient').innerHTML)
125 alert("<?php echo htmlspecialchars(xl('Take Insurance, from Drop Down'), ENT_QUOTES) ?>");
126 document.getElementById('type_code').focus();
127 return false;
129 top.restoreSession();
130 document.forms[0].submit();
132 function OnloadAction()
133 {//Displays message after upload action,and popups the details.
134 after_value=document.getElementById('after_value').value;
135 if(after_value!='')
137 alert(after_value);
139 <?php
140 if ($_FILES['form_erafile']['size']) {
142 var f = document.forms[0];
143 var debug = <?php echo htmlspecialchars($_REQUEST['form_without']*1);?> ;
144 var paydate = f.check_date.value;
145 var post_to_date = f.post_to_date.value;
146 var deposit_date = f.deposit_date.value;
147 window.open('sl_eob_process.php?eraname=<?php echo htmlspecialchars($eraname); ?>&debug=' + debug + '&paydate=' + paydate + '&post_to_date=' + post_to_date + '&deposit_date=' + deposit_date + '&original=original' + '&InsId=<?php echo htmlspecialchars(formData('hidden_type_code')); ?>' , '_blank');
148 return false;
149 <?php
154 $(document).ready(function() {
155 $('.datepicker').datetimepicker({
156 <?php $datetimepicker_timepicker = false; ?>
157 <?php $datetimepicker_showseconds = false; ?>
158 <?php $datetimepicker_formatInput = true; ?>
159 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
160 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
163 </script>
164 <script language="javascript" type="text/javascript">
165 document.onclick=HideTheAjaxDivs;
166 </script>
167 <style>
168 #ajax_div_insurance {
169 position: absolute;
170 z-index:10;
171 background-color: #FBFDD0;
172 border: 1px solid #ccc;
173 padding: 10px;
175 .bottom{border-bottom:1px solid black;}
176 .top{border-top:1px solid black;}
177 .left{border-left:1px solid black;}
178 .right{border-right:1px solid black;}
179 </style>
180 </head>
181 <body class="body_top" onLoad="OnloadAction()">
182 <form enctype="multipart/form-data" method='post' action='era_payments.php' style="display:inline" >
183 <table width="455" border="0" cellspacing="0" cellpadding="0">
184 <tr>
185 <td colspan="3" align="left"><b><?php echo htmlspecialchars(xl('Payments'), ENT_QUOTES) ?></b></td>
186 </tr>
187 <tr height="15">
188 <td colspan="3" align="left" ></td>
189 </tr>
190 <tr>
191 <td colspan="3" align="left">
192 <ul class="tabNav">
193 <li><a href='new_payment.php'><?php echo htmlspecialchars(xl('New Payment'), ENT_QUOTES) ?></a></li>
194 <li><a href='search_payments.php'><?php echo htmlspecialchars(xl('Search Payment'), ENT_QUOTES) ?></a></li>
195 <li class='current'><a href='era_payments.php'><?php echo htmlspecialchars(xl('ERA Posting'), ENT_QUOTES) ?></a></li>
196 </ul> </td>
197 </tr>
198 <tr>
199 <td colspan="3" align="left" >
200 <table width="455" border="0" cellspacing="0" cellpadding="10" bgcolor="#DEDEDE"><tr><td>
201 <table width="435" border="0" style="border:1px solid black" cellspacing="0" cellpadding="0">
202 <tr height="5">
203 <td width="5" align="left" ></td>
204 <td width="85" align="left" ></td>
205 <td width="105" align="left" ></td>
206 <td width="240" align="left" ></td>
207 </tr>
208 <tr>
209 <td align="left"></td>
210 <td colspan="3" align="left"><font class='title'><?php echo htmlspecialchars(xl('ERA'), ENT_QUOTES) ?></font></td>
211 </tr>
212 <tr height="5">
213 <td align="left" ></td>
214 <td colspan="3" align="left" ></td>
215 </tr>
216 <tr>
217 <td align="left" class="text"></td>
218 <td align="left" class="text"><?php echo htmlspecialchars(xl('Date'), ENT_QUOTES).':' ?></td>
219 <td align="left" class="text"><input type='text' size='6' class='datepicker' name='check_date' id='check_date' value="<?php echo formData('check_date') ?>" class="class1 text " onKeyDown="PreventIt(event)" />
220 </td>
221 <td align="left" class="text"><input type="hidden" name="MAX_FILE_SIZE" value="5000000" />
222 <input name="form_erafile" id="uploadedfile" type="file" class="text" size="10" style="display:inline" /></td>
223 </tr>
224 <tr>
225 <td align="left" class="text"></td>
226 <td align="left" class="text"><?php echo htmlspecialchars(xl('Post To Date'), ENT_QUOTES).':' ?></td>
227 <td align="left" class="text"><input type='text' size='6' class='datepicker' name='post_to_date' id='post_to_date' value="<?php echo formData('post_to_date') ?>" class="class1 text " onKeyDown="PreventIt(event)" />
228 </td>
229 <td align="left" class="text"><input type='checkbox' name='form_without' value='1' <?php echo $_REQUEST['form_without']*1==1 || ($_REQUEST['form_without']*1==0 && !isset($_FILES['form_erafile'])) ? "checked" : '' ?>/> <?php echo htmlspecialchars(xl('Without Update'), ENT_QUOTES); ?></td>
230 </tr>
231 <tr>
232 <td align="left" class="text"></td>
233 <td align="left" class="text"><?php echo htmlspecialchars(xl('Deposit Date'), ENT_QUOTES).':' ?></td>
234 <td align="left" class="text"><input type='text' size='6' class='datepicker' name='deposit_date' id='deposit_date' onKeyDown="PreventIt(event)" class="text " value="<?php echo formData('deposit_date') ?>" />
235 </td>
236 <td align="left" class="text"></td>
237 </tr>
238 <tr>
239 <td align="left" class="text"></td>
240 <td align="left" class="text"><?php echo htmlspecialchars(xl('Insurance'), ENT_QUOTES).':' ?></td>
241 <td colspan="2" align="left" class="text">
244 <table width="335" border="0" cellspacing="0" cellpadding="0">
245 <tr>
246 <td width="280">
247 <input type="hidden" id="hidden_ajax_close_value" value="<?php echo formData('type_code') ?>" /><input name='type_code' id='type_code' class="text "
248 style=" width:280px;" onKeyDown="PreventIt(event)" value="<?php echo formData('type_code') ?>" autocomplete="off" /><br>
249 <!--onKeyUp="ajaxFunction(event,'non','search_payments.php');"-->
250 <div id='ajax_div_insurance_section'>
251 <div id='ajax_div_insurance_error'>
252 </div>
253 <div id="ajax_div_insurance" style="display:none;"></div>
254 </div>
255 </div>
257 </td>
258 <td width="50" style="padding-left:5px;"><div name="div_insurance_or_patient" id="div_insurance_or_patient" class="text" style="border:1px solid black; padding-left:5px; width:50px; height:17px;"><?php echo formData('hidden_type_code') ?></div><input type="hidden" name="description" id="description" /></td>
259 </tr>
260 </table>
265 </td>
266 </tr>
268 <tr height="5">
269 <td colspan="4" align="center" ><table border="0" cellspacing="0" cellpadding="0">
270 <tr>
271 <td><a href="#" onClick="javascript:return Validate();" class="css_button"><span><?php echo htmlspecialchars(xl('Process ERA File'), ENT_QUOTES);?></span></a></td>
272 </tr>
273 </table></td>
274 </tr>
275 <tr height="5">
276 <td align="left" ></td>
277 <td colspan="3" align="left" ></td>
278 </tr>
279 </table>
280 </td></tr>
281 </table>
282 </td>
283 </tr>
284 </table>
285 <input type="hidden" name="after_value" id="after_value" value="<?php echo htmlspecialchars($alertmsg, ENT_QUOTES);?>"/>
286 <input type="hidden" name="hidden_type_code" id="hidden_type_code" value="<?php echo formData('hidden_type_code') ?>"/>
287 <input type='hidden' name='ajax_mode' id='ajax_mode' value='' />
288 </form>
289 </body>
290 </html>