Bug fix for provider Insurance Numbers
[openemr.git] / interface / billing / era_payments.php
blob0e8c12d5b75a7273ff96375a83ca3bc0b4ffd9fd
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.
22 //
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/sql-ledger.inc");
33 require_once("$srcdir/invoice_summary.inc.php");
34 require_once($GLOBALS['OE_SITE_DIR'] . "/statement.inc.php");
35 require_once("$srcdir/parse_era.inc.php");
36 require_once("$srcdir/sl_eob.inc.php");
37 require_once("$srcdir/formatting.inc.php");
38 //===============================================================================
39 // This is called back by parse_era() if we are processing X12 835's.
40 $alertmsg = '';
41 $where = '';
42 $eraname = '';
43 $eracount = 0;
44 $Processed=0;
45 function era_callback(&$out) {
46 global $where, $eracount, $eraname, $INTEGRATED_AR;
47 ++$eracount;
48 $eraname = $out['gs_date'] . '_' . ltrim($out['isa_control_number'], '0') .
49 '_' . ltrim($out['payer_id'], '0');
50 list($pid, $encounter, $invnumber) = slInvoiceNumber($out);
51 if ($pid && $encounter) {
52 if ($where) $where .= ' OR ';
53 if ($INTEGRATED_AR) {
54 $where .= "( f.pid = '$pid' AND f.encounter = '$encounter' )";
55 } else {
56 $where .= "invnumber = '$invnumber'";
60 //===============================================================================
61 // Handle X12 835 file upload.
62 if ($_FILES['form_erafile']['size']) {
63 $tmp_name = $_FILES['form_erafile']['tmp_name'];
64 // Handle .zip extension if present. Probably won't work on Windows.
65 if (strtolower(substr($_FILES['form_erafile']['name'], -4)) == '.zip') {
66 rename($tmp_name, "$tmp_name.zip");
67 exec("unzip -p $tmp_name.zip > $tmp_name");
68 unlink("$tmp_name.zip");
70 $alertmsg .= parse_era($tmp_name, 'era_callback');
71 $erafullname = $GLOBALS['OE_SITE_DIR'] . "/era/$eraname.edi";
72 if (is_file($erafullname)) {
73 $alertmsg .= xl("Warning").': '. xl("Set").' '.$eraname.' '. xl("was already uploaded").' ';
74 if (is_file($GLOBALS['OE_SITE_DIR'] . "/era/$eraname.html"))
76 $Processed=1;
77 $alertmsg .= xl("and processed.").' ';
79 else
80 $alertmsg .= xl("but not yet processed.").' ';;
82 rename($tmp_name, $erafullname);
83 } // End 835 upload
84 //===============================================================================
85 $DateFormat=DateFormatRead();
86 //===============================================================================
88 <html>
89 <head>
90 <?php if (function_exists('html_header_show')) html_header_show(); ?>
92 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
93 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/dialog.js"></script>
95 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
96 <link rel="stylesheet" type="text/css" href="../../library/js/fancybox/jquery.fancybox-1.2.6.css" media="screen" />
97 <style type="text/css">@import url(../../library/dynarch_calendar.css);</style>
98 <script type="text/javascript" src="../../library/textformat.js"></script>
99 <script type="text/javascript" src="../../library/dynarch_calendar.js"></script>
100 <?php include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?>
101 <script type="text/javascript" src="../../library/dynarch_calendar_setup.js"></script>
102 <script type="text/javascript" src="../../library/dialog.js"></script>
103 <script type="text/javascript" src="../../library/js/jquery.1.3.2.js"></script>
104 <?php include_once("{$GLOBALS['srcdir']}/ajax/payment_ajax_jav.inc.php"); ?>
105 <script type="text/javascript" src="../../library/js/common.js"></script>
106 <script type="text/javascript" src="../../library/js/fancybox/jquery.fancybox-1.2.6.js"></script>
107 <script language='JavaScript'>
108 var mypcc = '1';
109 </script>
110 <script type="text/javascript" language="javascript" >
111 function Validate()
113 if(document.getElementById('uploadedfile').value=='')
115 alert("<?php echo htmlspecialchars( xl('Please Choose a file'), ENT_QUOTES) ?>");
116 return false;
118 if(document.getElementById('hidden_type_code').value=='')
120 alert("<?php echo htmlspecialchars( xl('Select Insurance, by typing'), ENT_QUOTES) ?>");
121 document.getElementById('type_code').focus();
122 return false;
124 if(document.getElementById('hidden_type_code').value!=document.getElementById('div_insurance_or_patient').innerHTML)
126 alert("<?php echo htmlspecialchars( xl('Take Insurance, from Drop Down'), ENT_QUOTES) ?>");
127 document.getElementById('type_code').focus();
128 return false;
130 top.restoreSession();
131 document.forms[0].submit();
133 function OnloadAction()
134 {//Displays message after upload action,and popups the details.
135 after_value=document.getElementById('after_value').value;
136 if(after_value!='')
138 alert(after_value);
140 <?php
141 if ($_FILES['form_erafile']['size']) {
143 var f = document.forms[0];
144 var debug = <?php echo htmlspecialchars($_REQUEST['form_without']*1);?> ;
145 var paydate = f.check_date.value;
146 var post_to_date = f.post_to_date.value;
147 var deposit_date = f.deposit_date.value;
148 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');
149 return false;
150 <?php
154 </script>
155 <script language="javascript" type="text/javascript">
156 document.onclick=HideTheAjaxDivs;
157 </script>
158 <style>
159 #ajax_div_insurance {
160 position: absolute;
161 z-index:10;
162 background-color: #FBFDD0;
163 border: 1px solid #ccc;
164 padding: 10px;
166 .bottom{border-bottom:1px solid black;}
167 .top{border-top:1px solid black;}
168 .left{border-left:1px solid black;}
169 .right{border-right:1px solid black;}
170 </style>
171 </head>
172 <body class="body_top" onLoad="OnloadAction()">
173 <form enctype="multipart/form-data" method='post' action='era_payments.php' style="display:inline" >
174 <table width="455" border="0" cellspacing="0" cellpadding="0">
175 <tr>
176 <td colspan="3" align="left"><b><?php echo htmlspecialchars( xl('Payments'), ENT_QUOTES) ?></b></td>
177 </tr>
178 <tr height="15">
179 <td colspan="3" align="left" ></td>
180 </tr>
181 <tr>
182 <td colspan="3" align="left">
183 <ul class="tabNav">
184 <li><a href='new_payment.php'><?php echo htmlspecialchars( xl('New Payment'), ENT_QUOTES) ?></a></li>
185 <li><a href='search_payments.php'><?php echo htmlspecialchars( xl('Search Payment'), ENT_QUOTES) ?></a></li>
186 <li class='current'><a href='era_payments.php'><?php echo htmlspecialchars( xl('ERA Posting'), ENT_QUOTES) ?></a></li>
187 </ul> </td>
188 </tr>
189 <tr>
190 <td colspan="3" align="left" >
191 <table width="455" border="0" cellspacing="0" cellpadding="10" bgcolor="#DEDEDE"><tr><td>
192 <table width="435" border="0" style="border:1px solid black" cellspacing="0" cellpadding="0">
193 <tr height="5">
194 <td width="5" align="left" ></td>
195 <td width="85" align="left" ></td>
196 <td width="105" align="left" ></td>
197 <td width="240" align="left" ></td>
198 </tr>
199 <tr>
200 <td align="left"></td>
201 <td colspan="3" align="left"><font class='title'><?php echo htmlspecialchars( xl('ERA'), ENT_QUOTES) ?></font></td>
202 </tr>
203 <tr height="5">
204 <td align="left" ></td>
205 <td colspan="3" align="left" ></td>
206 </tr>
207 <tr>
208 <td align="left" class="text"></td>
209 <td align="left" class="text"><?php echo htmlspecialchars( xl('Date'), ENT_QUOTES).':' ?></td>
210 <td align="left" class="text"><input type='text' size='6' name='check_date' id='check_date' value="<?php echo formData('check_date') ?>" class="class1 text " onKeyDown="PreventIt(event)" />
211 <img src='../../interface/main/calendar/modules/PostCalendar/pntemplates/default/images/new.jpg' align='texttop'
212 id='img_checkdate' border='0' alt='[?]' style='cursor:pointer'
213 title='<?php echo htmlspecialchars( xl('Click here to choose a date'), ENT_QUOTES); ?>' />
214 <script>
215 Calendar.setup({inputField:"check_date", ifFormat:"<?php echo $DateFormat; ?>", button:"img_checkdate"});
216 </script></td>
217 <td align="left" class="text"><input type="hidden" name="MAX_FILE_SIZE" value="5000000" />
218 <input name="form_erafile" id="uploadedfile" type="file" class="text" size="10" style="display:inline" /></td>
219 </tr>
220 <tr>
221 <td align="left" class="text"></td>
222 <td align="left" class="text"><?php echo htmlspecialchars( xl('Post To Date'), ENT_QUOTES).':' ?></td>
223 <td align="left" class="text"><input type='text' size='6' name='post_to_date' id='post_to_date' value="<?php echo formData('post_to_date') ?>" class="class1 text " onKeyDown="PreventIt(event)" />
224 <img src='../../interface/main/calendar/modules/PostCalendar/pntemplates/default/images/new.jpg' align='texttop'
225 id='img_post_to_date' border='0' alt='[?]' style='cursor:pointer'
226 title='<?php echo htmlspecialchars( xl('Click here to choose a date'), ENT_QUOTES); ?>' />
227 <script>
228 Calendar.setup({inputField:"post_to_date", ifFormat:"<?php echo $DateFormat; ?>", button:"img_post_to_date"});
229 </script></td>
230 <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>
231 </tr>
232 <tr>
233 <td align="left" class="text"></td>
234 <td align="left" class="text"><?php echo htmlspecialchars( xl('Deposit Date'), ENT_QUOTES).':' ?></td>
235 <td align="left" class="text"><input type='text' size='6' name='deposit_date' id='deposit_date' onKeyDown="PreventIt(event)" class="text " value="<?php echo formData('deposit_date') ?>" />
236 <img src='../../interface/main/calendar/modules/PostCalendar/pntemplates/default/images/new.jpg' align='texttop'
237 id='img_depositdate' border='0' alt='[?]' style='cursor:pointer'
238 title='<?php echo htmlspecialchars( xl('Click here to choose a date'), ENT_QUOTES); ?>' />
239 <script>
240 Calendar.setup({inputField:"deposit_date", ifFormat:"<?php echo $DateFormat; ?>", button:"img_depositdate"});
241 </script></td>
242 <td align="left" class="text"></td>
243 </tr>
244 <tr>
245 <td align="left" class="text"></td>
246 <td align="left" class="text"><?php echo htmlspecialchars( xl('Insurance'), ENT_QUOTES).':' ?></td>
247 <td colspan="2" align="left" class="text">
250 <table width="335" border="0" cellspacing="0" cellpadding="0">
251 <tr>
252 <td width="280">
253 <input type="hidden" id="hidden_ajax_close_value" value="<?php echo formData('type_code') ?>" /><input name='type_code' id='type_code' class="text "
254 style=" width:280px;" onKeyDown="PreventIt(event)" value="<?php echo formData('type_code') ?>" autocomplete="off" /><br>
255 <!--onKeyUp="ajaxFunction(event,'non','search_payments.php');"-->
256 <div id='ajax_div_insurance_section'>
257 <div id='ajax_div_insurance_error'>
258 </div>
259 <div id="ajax_div_insurance" style="display:none;"></div>
260 </div>
261 </div>
263 </td>
264 <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>
265 </tr>
266 </table>
271 </td>
272 </tr>
274 <tr height="5">
275 <td colspan="4" align="center" ><table border="0" cellspacing="0" cellpadding="0">
276 <tr>
277 <td><a href="#" onClick="javascript:return Validate();" class="css_button"><span><?php echo htmlspecialchars( xl('Process ERA File'), ENT_QUOTES);?></span></a></td>
278 </tr>
279 </table></td>
280 </tr>
281 <tr height="5">
282 <td align="left" ></td>
283 <td colspan="3" align="left" ></td>
284 </tr>
285 </table>
286 </td></tr>
287 </table>
288 </td>
289 </tr>
290 </table>
291 <input type="hidden" name="after_value" id="after_value" value="<?php echo htmlspecialchars($alertmsg, ENT_QUOTES);?>"/>
292 <input type="hidden" name="hidden_type_code" id="hidden_type_code" value="<?php echo formData('hidden_type_code') ?>"/>
293 <input type='hidden' name='ajax_mode' id='ajax_mode' value='' />
294 </form>
295 </body>
296 </html>