New login interface with new login.css.
[openemr.git] / interface / billing / edit_payment.php
bloba777dadb06e1d29520c9d5b19425112c661d69d6
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 //Payments can be edited here.It includes deletion of an allocation,modifying the
29 //same or adding a new allocation.Log is kept for the deleted ones.
30 //===============================================================================
31 require_once("../globals.php");
32 require_once("$srcdir/log.inc");
33 require_once("$srcdir/invoice_summary.inc.php");
34 require_once("$srcdir/sl_eob.inc.php");
35 require_once("$srcdir/parse_era.inc.php");
36 require_once("../../library/acl.inc");
37 require_once("$srcdir/sql.inc");
38 require_once("$srcdir/auth.inc");
39 require_once("$srcdir/formdata.inc.php");
40 require_once("../../custom/code_types.inc.php");
41 require_once("$srcdir/patient.inc");
42 require_once("$srcdir/billrep.inc");
43 require_once(dirname(__FILE__) . "/../../library/classes/OFX.class.php");
44 require_once(dirname(__FILE__) . "/../../library/classes/X12Partner.class.php");
45 require_once("$srcdir/options.inc.php");
46 require_once("$srcdir/formatting.inc.php");
47 require_once("$srcdir/payment.inc.php");
48 //===============================================================================
49 $screen='edit_payment';
50 //===============================================================================
51 // deletion of payment distribution code
52 //===============================================================================
53 if (isset($_POST["mode"]))
55 if ($_POST["mode"] == "DeletePaymentDistribution")
57 $DeletePaymentDistributionId=trim(formData('DeletePaymentDistributionId' ));
58 $DeletePaymentDistributionIdArray=split('_',$DeletePaymentDistributionId);
59 $payment_id=$DeletePaymentDistributionIdArray[0];
60 $PId=$DeletePaymentDistributionIdArray[1];
61 $Encounter=$DeletePaymentDistributionIdArray[2];
62 $Code=$DeletePaymentDistributionIdArray[3];
63 $Modifier=$DeletePaymentDistributionIdArray[4];
64 //delete and log that action
65 row_delete("ar_activity", "session_id ='$payment_id' and pid ='$PId' AND " .
66 "encounter='$Encounter' and code='$Code' and modifier='$Modifier'");
67 $Message='Delete';
68 //------------------
69 $_POST["mode"] = "searchdatabase";
72 //===============================================================================
73 //Modify Payment Code.
74 //===============================================================================
75 if (isset($_POST["mode"]))
77 if ($_POST["mode"] == "ModifyPayments" || $_POST["mode"] == "FinishPayments")
79 $payment_id=$_REQUEST['payment_id'];
80 //ar_session Code
81 //===============================================================================
82 if(trim(formData('type_name' ))=='insurance')
84 $QueryPart="payer_id = '" . trim(formData('hidden_type_code' )) .
85 "', patient_id = '" . 0 ;
87 elseif(trim(formData('type_name' ))=='patient')
89 $QueryPart="payer_id = '" . 0 .
90 "', patient_id = '" . trim(formData('hidden_type_code' )) ;
92 $user_id=$_SESSION['authUserID'];
93 $closed=0;
94 $modified_time = date('Y-m-d H:i:s');
95 $check_date=DateToYYYYMMDD(formData('check_date'));
96 $deposit_date=DateToYYYYMMDD(formData('deposit_date'));
97 $post_to_date=DateToYYYYMMDD(formData('post_to_date'));
98 if($post_to_date=='')
99 $post_to_date=date('Y-m-d');
100 if(formData('deposit_date')=='')
101 $deposit_date=$post_to_date;
103 sqlStatement("update ar_session set " .
104 $QueryPart .
105 "', user_id = '" . trim($user_id ) .
106 "', closed = '" . trim($closed ) .
107 "', reference = '" . trim(formData('check_number' )) .
108 "', check_date = '" . trim($check_date ) .
109 "', deposit_date = '" . trim($deposit_date ) .
110 "', pay_total = '" . trim(formData('payment_amount')) .
111 "', modified_time = '" . trim($modified_time ) .
112 "', payment_type = '" . trim(formData('type_name' )) .
113 "', description = '" . trim(formData('description' )) .
114 "', adjustment_code = '" . trim(formData('adjustment_code' )) .
115 "', post_to_date = '" . trim($post_to_date ) .
116 "', payment_method = '" . trim(formData('payment_method' )) .
117 "' where session_id='$payment_id'");
118 //===============================================================================
119 $CountIndexAbove=$_REQUEST['CountIndexAbove'];
120 $CountIndexBelow=$_REQUEST['CountIndexBelow'];
121 $hidden_patient_code=$_REQUEST['hidden_patient_code'];
122 $user_id=$_SESSION['authUserID'];
123 $created_time = date('Y-m-d H:i:s');
124 //==================================================================
125 //UPDATION
126 //It is done with out deleting any old entries.
127 //==================================================================
128 for($CountRow=1;$CountRow<=$CountIndexAbove;$CountRow++)
130 if (isset($_POST["HiddenEncounter$CountRow"]))
132 if (isset($_POST["Payment$CountRow"]) && $_POST["Payment$CountRow"]*1>0)
134 if(trim(formData('type_name' ))=='insurance')
136 if(trim(formData("HiddenIns$CountRow" ))==1)
138 $AccountCode="IPP";
140 if(trim(formData("HiddenIns$CountRow" ))==2)
142 $AccountCode="ISP";
144 if(trim(formData("HiddenIns$CountRow" ))==3)
146 $AccountCode="ITP";
149 elseif(trim(formData('type_name' ))=='patient')
151 $AccountCode="PP";
153 $resPayment = sqlStatement("SELECT * from ar_activity " .
154 " where session_id ='$payment_id' and pid ='" . trim(formData("HiddenPId$CountRow" )) .
155 "' and encounter ='" . trim(formData("HiddenEncounter$CountRow" )) .
156 "' and code ='" . trim(formData("HiddenCode$CountRow" )) .
157 "' and modifier ='" . trim(formData("HiddenModifier$CountRow" )) .
158 "' and pay_amount>0");
159 if(sqlNumRows($resPayment)>0)
161 sqlStatement("update ar_activity set " .
162 " post_user = '" . trim($user_id ) .
163 "', modified_time = '" . trim($created_time ) .
164 "', pay_amount = '" . trim(formData("Payment$CountRow" )) .
165 "', account_code = '" . "$AccountCode" .
166 "', payer_type = '" . trim(formData("HiddenIns$CountRow" )) .
167 "', reason_code = '" . trim(formData("ReasonCode$CountRow" )) .
168 "' where session_id ='$payment_id' and pid ='" . trim(formData("HiddenPId$CountRow" )) .
169 "' and encounter ='" . trim(formData("HiddenEncounter$CountRow" )) .
170 "' and code ='" . trim(formData("HiddenCode$CountRow" )) .
171 "' and modifier ='" . trim(formData("HiddenModifier$CountRow" )) .
172 "' and pay_amount>0");
174 else
176 sqlStatement("insert into ar_activity set " .
177 "pid = '" . trim(formData("HiddenPId$CountRow" )) .
178 "', encounter = '" . trim(formData("HiddenEncounter$CountRow" )) .
179 "', code = '" . trim(formData("HiddenCode$CountRow" )) .
180 "', modifier = '" . trim(formData("HiddenModifier$CountRow" )) .
181 "', payer_type = '" . trim(formData("HiddenIns$CountRow" )) .
182 "', reason_code = '" . trim(formData("ReasonCode$CountRow" )) .
183 "', post_time = '" . trim($created_time ) .
184 "', post_user = '" . trim($user_id ) .
185 "', session_id = '" . trim(formData('payment_id')) .
186 "', modified_time = '" . trim($created_time ) .
187 "', pay_amount = '" . trim(formData("Payment$CountRow" )) .
188 "', adj_amount = '" . 0 .
189 "', account_code = '" . "$AccountCode" .
190 "'");
193 else
195 sqlStatement("delete from ar_activity " .
196 " where session_id ='$payment_id' and pid ='" . trim(formData("HiddenPId$CountRow" )) .
197 "' and encounter ='" . trim(formData("HiddenEncounter$CountRow" )) .
198 "' and code ='" . trim(formData("HiddenCode$CountRow" )) .
199 "' and modifier ='" . trim(formData("HiddenModifier$CountRow" )) .
200 "' and pay_amount>0");
202 //==============================================================================================================================
203 if (isset($_POST["AdjAmount$CountRow"]) && $_POST["AdjAmount$CountRow"]*1!=0)
205 if(trim(formData('type_name' ))=='insurance')
207 $AdjustString="Ins adjust Ins".trim(formData("HiddenIns$CountRow" ));
208 $AccountCode="IA";
210 elseif(trim(formData('type_name' ))=='patient')
212 $AdjustString="Pt adjust";
213 $AccountCode="PA";
215 $resPayment = sqlStatement("SELECT * from ar_activity " .
216 " where session_id ='$payment_id' and pid ='" . trim(formData("HiddenPId$CountRow" )) .
217 "' and encounter ='" . trim(formData("HiddenEncounter$CountRow" )) .
218 "' and code ='" . trim(formData("HiddenCode$CountRow" )) .
219 "' and modifier ='" . trim(formData("HiddenModifier$CountRow" )) .
220 "' and adj_amount!=0");
221 if(sqlNumRows($resPayment)>0)
223 sqlStatement("update ar_activity set " .
224 " post_user = '" . trim($user_id ) .
225 "', modified_time = '" . trim($created_time ) .
226 "', adj_amount = '" . trim(formData("AdjAmount$CountRow" )) .
227 "', memo = '" . "$AdjustString" .
228 "', account_code = '" . "$AccountCode" .
229 "', payer_type = '" . trim(formData("HiddenIns$CountRow" )) .
230 "' where session_id ='$payment_id' and pid ='" . trim(formData("HiddenPId$CountRow" )) .
231 "' and encounter ='" . trim(formData("HiddenEncounter$CountRow" )) .
232 "' and code ='" . trim(formData("HiddenCode$CountRow" )) .
233 "' and modifier ='" . trim(formData("HiddenModifier$CountRow" )) .
234 "' and adj_amount!=0");
236 else
238 sqlStatement("insert into ar_activity set " .
239 "pid = '" . trim(formData("HiddenPId$CountRow" )) .
240 "', encounter = '" . trim(formData("HiddenEncounter$CountRow" )) .
241 "', code = '" . trim(formData("HiddenCode$CountRow" )) .
242 "', modifier = '" . trim(formData("HiddenModifier$CountRow" )) .
243 "', payer_type = '" . trim(formData("HiddenIns$CountRow" )) .
244 "', post_time = '" . trim($created_time ) .
245 "', post_user = '" . trim($user_id ) .
246 "', session_id = '" . trim(formData('payment_id')) .
247 "', modified_time = '" . trim($created_time ) .
248 "', pay_amount = '" . 0 .
249 "', adj_amount = '" . trim(formData("AdjAmount$CountRow" )) .
250 "', memo = '" . "$AdjustString" .
251 "', account_code = '" . "$AccountCode" .
252 "'");
256 else
258 sqlStatement("delete from ar_activity " .
259 " where session_id ='$payment_id' and pid ='" . trim(formData("HiddenPId$CountRow" )) .
260 "' and encounter ='" . trim(formData("HiddenEncounter$CountRow" )) .
261 "' and code ='" . trim(formData("HiddenCode$CountRow" )) .
262 "' and modifier ='" . trim(formData("HiddenModifier$CountRow" )) .
263 "' and adj_amount!=0");
265 //==============================================================================================================================
266 if (isset($_POST["Deductible$CountRow"]) && $_POST["Deductible$CountRow"]*1>0)
268 $resPayment = sqlStatement("SELECT * from ar_activity " .
269 " where session_id ='$payment_id' and pid ='" . trim(formData("HiddenPId$CountRow" )) .
270 "' and encounter ='" . trim(formData("HiddenEncounter$CountRow" )) .
271 "' and code ='" . trim(formData("HiddenCode$CountRow" )) .
272 "' and modifier ='" . trim(formData("HiddenModifier$CountRow" )) .
273 "' and memo like 'Deductable%'");
274 if(sqlNumRows($resPayment)>0)
276 sqlStatement("update ar_activity set " .
277 " post_user = '" . trim($user_id ) .
278 "', modified_time = '" . trim($created_time ) .
279 "', memo = '" . "Deductable $".trim(formData("Deductible$CountRow" )) .
280 "', account_code = '" . "Deduct" .
281 "', payer_type = '" . trim(formData("HiddenIns$CountRow" )) .
282 "' where session_id ='$payment_id' and pid ='" . trim(formData("HiddenPId$CountRow" )) .
283 "' and encounter ='" . trim(formData("HiddenEncounter$CountRow" )) .
284 "' and code ='" . trim(formData("HiddenCode$CountRow" )) .
285 "' and modifier ='" . trim(formData("HiddenModifier$CountRow" )) .
286 "' and memo like 'Deductable%'");
288 else
290 sqlStatement("insert into ar_activity set " .
291 "pid = '" . trim(formData("HiddenPId$CountRow" )) .
292 "', encounter = '" . trim(formData("HiddenEncounter$CountRow" )) .
293 "', code = '" . trim(formData("HiddenCode$CountRow" )) .
294 "', modifier = '" . trim(formData("HiddenModifier$CountRow" )) .
295 "', payer_type = '" . trim(formData("HiddenIns$CountRow" )) .
296 "', post_time = '" . trim($created_time ) .
297 "', post_user = '" . trim($user_id ) .
298 "', session_id = '" . trim(formData('payment_id')) .
299 "', modified_time = '" . trim($created_time ) .
300 "', pay_amount = '" . 0 .
301 "', adj_amount = '" . 0 .
302 "', memo = '" . "Deductable $".trim(formData("Deductible$CountRow" )) .
303 "', account_code = '" . "Deduct" .
304 "'");
307 else
309 sqlStatement("delete from ar_activity " .
310 " where session_id ='$payment_id' and pid ='" . trim(formData("HiddenPId$CountRow" )) .
311 "' and encounter ='" . trim(formData("HiddenEncounter$CountRow" )) .
312 "' and code ='" . trim(formData("HiddenCode$CountRow" )) .
313 "' and modifier ='" . trim(formData("HiddenModifier$CountRow" )) .
314 "' and memo like 'Deductable%'");
316 //==============================================================================================================================
317 if (isset($_POST["Takeback$CountRow"]) && $_POST["Takeback$CountRow"]*1>0)
319 $resPayment = sqlStatement("SELECT * from ar_activity " .
320 " where session_id ='$payment_id' and pid ='" . trim(formData("HiddenPId$CountRow" )) .
321 "' and encounter ='" . trim(formData("HiddenEncounter$CountRow" )) .
322 "' and code ='" . trim(formData("HiddenCode$CountRow" )) .
323 "' and modifier ='" . trim(formData("HiddenModifier$CountRow" )) .
324 "' and pay_amount < 0");
325 if(sqlNumRows($resPayment)>0)
327 sqlStatement("update ar_activity set " .
328 " post_user = '" . trim($user_id ) .
329 "', modified_time = '" . trim($created_time ) .
330 "', pay_amount = '" . trim(formData("Takeback$CountRow" ))*-1 .
331 "', account_code = '" . "Takeback" .
332 "', payer_type = '" . trim(formData("HiddenIns$CountRow" )) .
333 "' where session_id ='$payment_id' and pid ='" . trim(formData("HiddenPId$CountRow" )) .
334 "' and encounter ='" . trim(formData("HiddenEncounter$CountRow" )) .
335 "' and code ='" . trim(formData("HiddenCode$CountRow" )) .
336 "' and modifier ='" . trim(formData("HiddenModifier$CountRow" )) .
337 "' and pay_amount < 0");
339 else
341 sqlStatement("insert into ar_activity set " .
342 "pid = '" . trim(formData("HiddenPId$CountRow" )) .
343 "', encounter = '" . trim(formData("HiddenEncounter$CountRow" )) .
344 "', code = '" . trim(formData("HiddenCode$CountRow" )) .
345 "', modifier = '" . trim(formData("HiddenModifier$CountRow" )) .
346 "', payer_type = '" . trim(formData("HiddenIns$CountRow" )) .
347 "', post_time = '" . trim($created_time ) .
348 "', post_user = '" . trim($user_id ) .
349 "', session_id = '" . trim(formData('payment_id')) .
350 "', modified_time = '" . trim($created_time ) .
351 "', pay_amount = '" . trim(formData("Takeback$CountRow" ))*-1 .
352 "', adj_amount = '" . 0 .
353 "', account_code = '" . "Takeback" .
354 "'");
357 else
359 sqlStatement("delete from ar_activity " .
360 " where session_id ='$payment_id' and pid ='" . trim(formData("HiddenPId$CountRow" )) .
361 "' and encounter ='" . trim(formData("HiddenEncounter$CountRow" )) .
362 "' and code ='" . trim(formData("HiddenCode$CountRow" )) .
363 "' and modifier ='" . trim(formData("HiddenModifier$CountRow" )) .
364 "' and pay_amount < 0");
366 //==============================================================================================================================
367 if (isset($_POST["FollowUp$CountRow"]) && $_POST["FollowUp$CountRow"]=='y')
369 $resPayment = sqlStatement("SELECT * from ar_activity " .
370 " where session_id ='$payment_id' and pid ='" . trim(formData("HiddenPId$CountRow" )) .
371 "' and encounter ='" . trim(formData("HiddenEncounter$CountRow" )) .
372 "' and code ='" . trim(formData("HiddenCode$CountRow" )) .
373 "' and modifier ='" . trim(formData("HiddenModifier$CountRow" )) .
374 "' and follow_up ='y'");
375 if(sqlNumRows($resPayment)>0)
377 sqlStatement("update ar_activity set " .
378 " post_user = '" . trim($user_id ) .
379 "', modified_time = '" . trim($created_time ) .
380 "', follow_up = '" . "y" .
381 "', follow_up_note = '" . trim(formData("FollowUpReason$CountRow" )) .
382 "', payer_type = '" . trim(formData("HiddenIns$CountRow" )) .
383 "' where session_id ='$payment_id' and pid ='" . trim(formData("HiddenPId$CountRow" )) .
384 "' and encounter ='" . trim(formData("HiddenEncounter$CountRow" )) .
385 "' and code ='" . trim(formData("HiddenCode$CountRow" )) .
386 "' and modifier ='" . trim(formData("HiddenModifier$CountRow" )) .
387 "' and follow_up ='y'");
389 else
391 sqlStatement("insert into ar_activity set " .
392 "pid = '" . trim(formData("HiddenPId$CountRow" )) .
393 "', encounter = '" . trim(formData("HiddenEncounter$CountRow" )) .
394 "', code = '" . trim(formData("HiddenCode$CountRow" )) .
395 "', modifier = '" . trim(formData("HiddenModifier$CountRow" )) .
396 "', payer_type = '" . trim(formData("HiddenIns$CountRow" )) .
397 "', post_time = '" . trim($created_time ) .
398 "', post_user = '" . trim($user_id ) .
399 "', session_id = '" . trim(formData('payment_id')) .
400 "', modified_time = '" . trim($created_time ) .
401 "', pay_amount = '" . 0 .
402 "', adj_amount = '" . 0 .
403 "', follow_up = '" . "y" .
404 "', follow_up_note = '" . trim(formData("FollowUpReason$CountRow" )) .
405 "'");
408 else
410 sqlStatement("delete from ar_activity " .
411 " where session_id ='$payment_id' and pid ='" . trim(formData("HiddenPId$CountRow" )) .
412 "' and encounter ='" . trim(formData("HiddenEncounter$CountRow" )) .
413 "' and code ='" . trim(formData("HiddenCode$CountRow" )) .
414 "' and modifier ='" . trim(formData("HiddenModifier$CountRow" )) .
415 "' and follow_up ='y'");
417 //==============================================================================================================================
419 else
420 break;
422 //=========
423 //INSERTION of new entries,continuation of modification.
424 //=========
425 for($CountRow=$CountIndexAbove+1;$CountRow<=$CountIndexAbove+$CountIndexBelow;$CountRow++)
427 if (isset($_POST["HiddenEncounter$CountRow"]))
429 DistributionInsert($CountRow,$created_time,$user_id);
431 else
432 break;
434 if($_REQUEST['global_amount']=='yes')
435 sqlStatement("update ar_session set global_amount=".trim(formData("HidUnappliedAmount" ))*1 ." where session_id ='$payment_id'");
436 if($_POST["mode"]=="FinishPayments")
438 $Message='Finish';
440 $_POST["mode"] = "searchdatabase";
441 $Message='Modify';
444 //==============================================================================
445 //Search Code
446 //===============================================================================
447 $payment_id=$payment_id*1 > 0 ? $payment_id : $_REQUEST['payment_id'];
448 $ResultSearchSub = sqlStatement("SELECT distinct encounter,code,modifier, pid from ar_activity where session_id ='$payment_id' order by pid,encounter,code,modifier");
449 //==============================================================================
450 $DateFormat=DateFormatRead();
451 //==============================================================================
452 //===============================================================================
455 <html>
456 <head>
457 <?php if (function_exists('html_header_show')) html_header_show(); ?>
459 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
461 <!-- supporting javascript code -->
463 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/dialog.js"></script>
467 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
468 <link rel="stylesheet" type="text/css" href="../../library/js/fancybox/jquery.fancybox-1.2.6.css" media="screen" />
469 <style type="text/css">@import url(../../library/dynarch_calendar.css);</style>
470 <script type="text/javascript" src="../../library/textformat.js"></script>
471 <script type="text/javascript" src="../../library/dynarch_calendar.js"></script>
472 <?php include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?>
473 <script type="text/javascript" src="../../library/dynarch_calendar_setup.js"></script>
474 <script type="text/javascript" src="../../library/dialog.js"></script>
475 <script type="text/javascript" src="../../library/js/jquery.1.3.2.js"></script>
476 <script type="text/javascript" src="../../library/js/fancybox/jquery.fancybox-1.2.6.js"></script>
477 <script language='JavaScript'>
478 var mypcc = '1';
479 </script>
480 <?php include_once("{$GLOBALS['srcdir']}/payment_jav.inc.php"); ?>
481 <?php include_once("{$GLOBALS['srcdir']}/ajax/payment_ajax_jav.inc.php"); ?>
482 <script type="text/javascript" src="../../library/js/common.js"></script>
483 <script LANGUAGE="javascript" TYPE="text/javascript">
484 function ModifyPayments()
485 {//Used while modifying the allocation
486 if(!FormValidations())//FormValidations contains the form checks
488 return false;
490 if(CompletlyBlankAbove())//The distribution rows already in the database are checked.
492 alert("<?php echo htmlspecialchars( xl('None of the Top Distribution Row Can be Completly Blank.'), ENT_QUOTES);echo htmlspecialchars('\n');echo htmlspecialchars( xl('Use Delete Option to Remove.'), ENT_QUOTES) ?>")
493 return false;
495 if(!CheckPayingEntityAndDistributionPostFor())//Ensures that Insurance payment is distributed under Ins1,Ins2,Ins3 and Patient paymentat under Pat.
497 return false;
499 if(CompletlyBlankBelow())//The newly added distribution rows are checked.
501 alert("<?php echo htmlspecialchars( xl('Fill any of the Below Row.'), ENT_QUOTES) ?>")
502 return false;
504 PostValue=CheckUnappliedAmount();//Decides TdUnappliedAmount >0, or <0 or =0
505 if(PostValue==1)
507 alert("<?php echo htmlspecialchars( xl('Cannot Modify Payments.Undistributed is Negative.'), ENT_QUOTES) ?>")
508 return false;
510 if(confirm("<?php echo htmlspecialchars( xl('Would you like to Modify Payments?'), ENT_QUOTES) ?>"))
512 document.getElementById('mode').value='ModifyPayments';
513 top.restoreSession();
514 document.forms[0].submit();
516 else
517 return false;
519 function FinishPayments()
521 if(!FormValidations())//FormValidations contains the form checks
523 return false;
525 if(CompletlyBlankAbove())//The distribution rows already in the database are checked.
527 alert("<?php echo htmlspecialchars( xl('None of the Top Distribution Row Can be Completly Blank.'), ENT_QUOTES);echo htmlspecialchars('\n');echo htmlspecialchars( xl('Use Delete Option to Remove.'), ENT_QUOTES) ?>")
528 return false;
530 if(!CheckPayingEntityAndDistributionPostFor())//Ensures that Insurance payment is distributed under Ins1,Ins2,Ins3 and Patient paymentat under Pat.
532 return false;
534 if(CompletlyBlankBelow())//The newly added distribution rows are checked.
536 alert("<?php echo htmlspecialchars( xl('Fill any of the Below Row.'), ENT_QUOTES) ?>")
537 return false;
539 PostValue=CheckUnappliedAmount();//Decides TdUnappliedAmount >0, or <0 or =0
540 if(PostValue==1)
542 alert("<?php echo htmlspecialchars( xl('Cannot Modify Payments.Undistributed is Negative.'), ENT_QUOTES) ?>")
543 return false;
545 if(PostValue==2)
547 if(confirm("<?php echo htmlspecialchars( xl('Would you like to Modify and Finish Payments?'), ENT_QUOTES) ?>"))
549 UnappliedAmount=document.getElementById('TdUnappliedAmount').innerHTML*1;
550 if(confirm("<?php echo htmlspecialchars( xl('Undistributed is'), ENT_QUOTES) ?>" + ' ' + UnappliedAmount + '.' + "<?php echo htmlspecialchars('\n');echo htmlspecialchars( xl('Would you like the balance amount to apply to Global Account?'), ENT_QUOTES) ?>"))
552 document.getElementById('mode').value='FinishPayments';
553 document.getElementById('global_amount').value='yes';
554 top.restoreSession();
555 document.forms[0].submit();
557 else
559 document.getElementById('mode').value='FinishPayments';
560 top.restoreSession();
561 document.forms[0].submit();
564 else
565 return false;
567 else
569 if(confirm("<?php echo htmlspecialchars( xl('Would you like to Modify and Finish Payments?'), ENT_QUOTES) ?>"))
571 document.getElementById('mode').value='FinishPayments';
572 top.restoreSession();
573 document.forms[0].submit();
575 else
576 return false;
580 function CompletlyBlankAbove()
581 {//The distribution rows already in the database are checked.
582 //It is not allowed to be made completly empty.If needed delete option need to be used.
583 CountIndexAbove=document.getElementById('CountIndexAbove').value*1;
584 for(RowCount=1;RowCount<=CountIndexAbove;RowCount++)
586 if(document.getElementById('Allowed'+RowCount).value=='' && document.getElementById('Payment'+RowCount).value=='' && document.getElementById('AdjAmount'+RowCount).value=='' && document.getElementById('Deductible'+RowCount).value=='' && document.getElementById('Takeback'+RowCount).value=='' && document.getElementById('FollowUp'+RowCount).checked==false)
588 return true;
591 return false;
593 function CompletlyBlankBelow()
594 {//The newly added distribution rows are checked.
595 //It is not allowed to be made completly empty.
596 CountIndexAbove=document.getElementById('CountIndexAbove').value*1;
597 CountIndexBelow=document.getElementById('CountIndexBelow').value*1;
598 if(CountIndexBelow==0)
599 return false;
600 for(RowCount=CountIndexAbove+1;RowCount<=CountIndexAbove+CountIndexBelow;RowCount++)
602 if(document.getElementById('Allowed'+RowCount).value=='' && document.getElementById('Payment'+RowCount).value=='' && document.getElementById('AdjAmount'+RowCount).value=='' && document.getElementById('Deductible'+RowCount).value=='' && document.getElementById('Takeback'+RowCount).value=='' && document.getElementById('FollowUp'+RowCount).checked==false)
606 else
607 return false;
609 return true;
611 function OnloadAction()
612 {//Displays message while loading after some action.
613 after_value=document.getElementById('ActionStatus').value;
614 if(after_value=='Delete')
616 alert("<?php echo htmlspecialchars( xl('Successfully Deleted'), ENT_QUOTES) ?>")
617 return true;
619 if(after_value=='Modify' || after_value=='Finish')
621 alert("<?php echo htmlspecialchars( xl('Successfully Modified'), ENT_QUOTES) ?>")
622 return true;
624 after_value=document.getElementById('after_value').value;
625 payment_id=document.getElementById('payment_id').value;
626 if(after_value=='distribute')
629 else if(after_value=='new_payment')
631 if(document.getElementById('TablePatientPortion'))
633 document.getElementById('TablePatientPortion').style.display='none';
635 if(confirm("<?php echo htmlspecialchars( xl('Successfully Saved.Would you like to Distribute?'), ENT_QUOTES) ?>"))
637 if(document.getElementById('TablePatientPortion'))
639 document.getElementById('TablePatientPortion').style.display='';
645 function DeletePaymentDistribution(DeleteId)
646 {//Confirms deletion of payment distribution.
647 if(confirm("<?php echo htmlspecialchars( xl('Would you like to Delete Payment Distribution?'), ENT_QUOTES) ?>"))
649 document.getElementById('mode').value='DeletePaymentDistribution';
650 document.getElementById('DeletePaymentDistributionId').value=DeleteId;
651 top.restoreSession();
652 document.forms[0].submit();
654 else
655 return false;
657 //========================================================================================
658 </script>
659 <script language="javascript" type="text/javascript">
660 document.onclick=HideTheAjaxDivs;
661 </script>
662 <style>
663 .class1{width:125px;}
664 .class2{width:250px;}
665 .class3{width:100px;}
666 .bottom{border-bottom:1px solid black;}
667 .top{border-top:1px solid black;}
668 .left{border-left:1px solid black;}
669 .right{border-right:1px solid black;}
670 #ajax_div_insurance {
671 position: absolute;
672 z-index:10;
674 left: 20px;
675 top: 300px;
677 background-color: #FBFDD0;
678 border: 1px solid #ccc;
679 padding: 10px;
681 #ajax_div_patient {
682 position: absolute;
683 z-index:10;
685 left: 20px;
686 top: 300px;
688 background-color: #FBFDD0;
689 border: 1px solid #ccc;
690 padding: 10px;
692 </style>
693 <link rel="stylesheet" href="<?php echo $css_header; ?>" type="text/css">
694 </head>
695 <body class="body_top" onLoad="OnloadAction()" >
696 <form name='new_payment' method='post' action="edit_payment.php" onsubmit='
697 <?php
698 if($payment_id*1==0)
701 top.restoreSession();return SavePayment();
702 <?php
704 else
707 return false;
708 <?php
711 ' style="display:inline" >
712 <table width="1024" border="0" cellspacing="0" cellpadding="0">
713 <?php
714 if($_REQUEST['ParentPage']=='new_payment')
717 <tr>
718 <td colspan="3" align="left"><b><?php echo htmlspecialchars( xl('Payments'), ENT_QUOTES) ?></b></td>
719 </tr>
720 <tr height="15">
721 <td colspan="3" align="left" ></td>
722 </tr>
723 <tr>
724 <td colspan="3" align="left">
725 <ul class="tabNav">
726 <li class='current'><a href='new_payment.php'><?php echo htmlspecialchars( xl('New Payment'), ENT_QUOTES) ?></a></li>
727 <li><a href='search_payments.php'><?php echo htmlspecialchars( xl('Search Payment'), ENT_QUOTES) ?></a></li>
728 <li><a href='era_payments.php'><?php echo htmlspecialchars( xl('ERA Posting'), ENT_QUOTES) ?></a></li>
729 </ul> </td>
730 </tr>
731 <?php
733 else
736 <tr height="5">
737 <td colspan="3" align="left" ></td>
738 </tr>
739 <?php
742 <tr>
743 <td colspan="3" align="left" >
745 <?php
746 if($payment_id*1>0)
749 <?php
750 require_once("payment_master.inc.php"); //Check/cash details are entered here.
752 <?php
755 </td>
756 </tr>
757 </table>
761 <?php
762 if($payment_id*1>0)
763 {//Distribution rows already in the database are displayed.
766 <table width="1024" border="0" cellspacing="0" cellpadding="10" bgcolor="#DEDEDE"><tr><td>
767 <table width="1004" border="0" cellspacing="0" cellpadding="0">
769 <tr>
770 <td colspan="13" align="left" >
772 <?php //
773 $resCount = sqlStatement("SELECT distinct encounter,code,modifier from ar_activity where session_id ='$payment_id' ");
774 $TotalRows=sqlNumRows($resCount);
775 $CountPatient=0;
776 $CountIndex=0;
777 $CountIndexAbove=0;
778 $paymenttot=0;
779 $adjamttot=0;
780 $deductibletot=0;
781 $takebacktot=0;
782 $allowedtot=0;
783 if($RowSearchSub = sqlFetchArray($ResultSearchSub))
787 $CountPatient++;
788 $PId=$RowSearchSub['pid'];
789 $EncounterMaster=$RowSearchSub['encounter'];
790 $CodeMaster=$RowSearchSub['code'];
791 $ModifierMaster=$RowSearchSub['modifier'];
792 $res = sqlStatement("SELECT fname,lname,mname FROM patient_data where pid ='$PId'");
793 $row = sqlFetchArray($res);
794 $fname=$row['fname'];
795 $lname=$row['lname'];
796 $mname=$row['mname'];
797 $NameDB=$lname.' '.$fname.' '.$mname;
798 $ResultSearch = sqlStatement("SELECT billing.id,last_level_closed,billing.encounter,form_encounter.`date`,billing.code,billing.modifier,fee
799 FROM billing ,form_encounter
800 where billing.encounter=form_encounter.encounter and billing.pid=form_encounter.pid and
801 code_type!='ICD9' and code_type!='COPAY' and billing.activity!=0 and
802 form_encounter.pid ='$PId' and billing.pid ='$PId' and billing.encounter ='$EncounterMaster'
803 and billing.code ='$CodeMaster'
804 and billing.modifier ='$ModifierMaster'
805 ORDER BY form_encounter.`date`,form_encounter.encounter,billing.code,billing.modifier");
806 if(sqlNumRows($ResultSearch)>0)
808 if($CountPatient==1)
810 $Table='yes';
812 <table width="1004" border="0" cellpadding="0" cellspacing="0" align="center" id="TableDistributePortion">
813 <tr class="text" bgcolor="#dddddd">
814 <td width="25" class="left top" >&nbsp;</td>
815 <td width="144" class="left top" ><?php echo htmlspecialchars( xl('Patient Name'), ENT_QUOTES) ?></td>
816 <td width="55" class="left top" ><?php echo htmlspecialchars( xl('Post For'), ENT_QUOTES) ?></td>
817 <td width="70" class="left top" ><?php echo htmlspecialchars( xl('Srv Date'), ENT_QUOTES) ?></td>
818 <td width="50" class="left top" ><?php echo htmlspecialchars( xl('Encnter'), ENT_QUOTES) ?></td>
819 <td width="65" class="left top" ><?php echo htmlspecialchars( xl('CPT Code'), ENT_QUOTES) ?></td>
820 <td width="50" class="left top" ><?php echo htmlspecialchars( xl('Charge'), ENT_QUOTES) ?></td>
821 <td width="40" class="left top" ><?php echo htmlspecialchars( xl('Copay'), ENT_QUOTES) ?></td>
822 <td width="40" class="left top" ><?php echo htmlspecialchars( xl('Remdr'), ENT_QUOTES) ?></td>
823 <td width="60" class="left top" ><?php echo htmlspecialchars( xl('Allowed(c)'), ENT_QUOTES) ?></td><!-- (c) means it is calculated.Not stored one. -->
824 <td width="60" class="left top" ><?php echo htmlspecialchars( xl('Payment'), ENT_QUOTES) ?></td>
825 <td width="70" class="left top" ><?php echo htmlspecialchars( xl('Adj Amount'), ENT_QUOTES) ?></td>
826 <td width="60" class="left top" ><?php echo htmlspecialchars( xl('Deductible'), ENT_QUOTES) ?></td>
827 <td width="60" class="left top" ><?php echo htmlspecialchars( xl('Takeback'), ENT_QUOTES) ?></td>
828 <td width="60" class="left top" ><?php echo htmlspecialchars( xl('MSP Code'), ENT_QUOTES) ?></td>
829 <td width="40" class="left top" ><?php echo htmlspecialchars( xl('Resn'), ENT_QUOTES) ?></td>
830 <td width="110" class="left top right" ><?php echo htmlspecialchars( xl('Follow Up Reason'), ENT_QUOTES) ?></td>
831 </tr>
832 <?php
834 while ($RowSearch = sqlFetchArray($ResultSearch))
836 $CountIndex++;
837 $CountIndexAbove++;
838 $ServiceDateArray=split(' ',$RowSearch['date']);
839 $ServiceDate=oeFormatShortDate($ServiceDateArray[0]);
840 $Code=$RowSearch['code'];
841 $Modifier =$RowSearch['modifier'];
842 if($Modifier!='')
843 $ModifierString=", $Modifier";
844 else
845 $ModifierString="";
846 $Fee=$RowSearch['fee'];
847 $Encounter=$RowSearch['encounter'];
849 $resPayer = sqlStatement("SELECT payer_type from ar_activity where session_id ='$payment_id' and
850 pid ='$PId' and encounter ='$Encounter' and code='$Code' and modifier='$Modifier' ");
851 $rowPayer = sqlFetchArray($resPayer);
852 $Ins=$rowPayer['payer_type'];
854 //Always associating the copay to a particular charge.
855 $BillingId=$RowSearch['id'];
856 $resId = sqlStatement("SELECT id FROM billing where code_type!='ICD9' and code_type!='COPAY' and
857 pid ='$PId' and encounter ='$Encounter' and billing.activity!=0 order by id");
858 $rowId = sqlFetchArray($resId);
859 $Id=$rowId['id'];
861 if($BillingId!=$Id)//multiple cpt in single encounter
863 $Copay=0.00;
865 else
867 $resCopay = sqlStatement("SELECT sum(fee) as copay FROM billing where
868 code_type='COPAY' and pid ='$PId' and encounter ='$Encounter' and billing.activity!=0");
869 $rowCopay = sqlFetchArray($resCopay);
870 $Copay=$rowCopay['copay']*-1;
872 $resMoneyGot = sqlStatement("SELECT sum(pay_amount) as PatientPay FROM ar_activity where
873 pid ='$PId' and encounter ='$Encounter' and payer_type=0 and
874 (code='CO-PAY' or account_code='PCP')");//new fees screen copay gives account_code='PCP'
875 //openemr payment screen copay gives code='CO-PAY'
876 $rowMoneyGot = sqlFetchArray($resMoneyGot);
877 $PatientPay=$rowMoneyGot['PatientPay'];
879 $Copay=$Copay+$PatientPay;
882 //For calculating Remainder
883 if($Ins==0)
884 {//Fetch all values
885 $resMoneyGot = sqlStatement("SELECT sum(pay_amount) as MoneyGot FROM ar_activity where
886 pid ='$PId' and code='$Code' and modifier='$Modifier' and encounter ='$Encounter' and !(payer_type=0 and
887 (code='CO-PAY' or account_code='PCP'))");
888 //new fees screen copay gives account_code='PCP'
889 //openemr payment screen copay gives code='CO-PAY'
890 $rowMoneyGot = sqlFetchArray($resMoneyGot);
891 $MoneyGot=$rowMoneyGot['MoneyGot'];
893 $resMoneyAdjusted = sqlStatement("SELECT sum(adj_amount) as MoneyAdjusted FROM ar_activity where
894 pid ='$PId' and code='$Code' and modifier='$Modifier' and encounter ='$Encounter'");
895 $rowMoneyAdjusted = sqlFetchArray($resMoneyAdjusted);
896 $MoneyAdjusted=$rowMoneyAdjusted['MoneyAdjusted'];
898 else//Fetch till that much got
900 //Fetch the HIGHEST sequence_no till this session.
901 //Used maily in the case if primary/others pays once more.
902 $resSequence = sqlStatement("SELECT sequence_no from ar_activity where session_id ='$payment_id' and
903 pid ='$PId' and encounter ='$Encounter' order by sequence_no desc ");
904 $rowSequence = sqlFetchArray($resSequence);
905 $Sequence=$rowSequence['sequence_no'];
907 $resMoneyGot = sqlStatement("SELECT sum(pay_amount) as MoneyGot FROM ar_activity where
908 pid ='$PId' and code='$Code' and modifier='$Modifier' and encounter ='$Encounter' and
909 payer_type > 0 and payer_type <='$Ins' and sequence_no<='$Sequence'");
910 $rowMoneyGot = sqlFetchArray($resMoneyGot);
911 $MoneyGot=$rowMoneyGot['MoneyGot'];
913 $resMoneyAdjusted = sqlStatement("SELECT sum(adj_amount) as MoneyAdjusted FROM ar_activity where
914 pid ='$PId' and code='$Code' and modifier='$Modifier' and encounter ='$Encounter' and
915 payer_type > 0 and payer_type <='$Ins' and sequence_no<='$Sequence'");
916 $rowMoneyAdjusted = sqlFetchArray($resMoneyAdjusted);
917 $MoneyAdjusted=$rowMoneyAdjusted['MoneyAdjusted'];
919 $Remainder=$Fee-$Copay-$MoneyGot-$MoneyAdjusted;
921 //For calculating RemainderJS.Used while restoring back the values.
922 if($Ins==0)
923 {//Got just before Patient
924 $resMoneyGot = sqlStatement("SELECT sum(pay_amount) as MoneyGot FROM ar_activity where
925 pid ='$PId' and code='$Code' and modifier='$Modifier' and encounter ='$Encounter' and payer_type !=0");
926 $rowMoneyGot = sqlFetchArray($resMoneyGot);
927 $MoneyGot=$rowMoneyGot['MoneyGot'];
929 $resMoneyAdjusted = sqlStatement("SELECT sum(adj_amount) as MoneyAdjusted FROM ar_activity where
930 pid ='$PId' and code='$Code' and modifier='$Modifier' and encounter ='$Encounter' and payer_type !=0");
931 $rowMoneyAdjusted = sqlFetchArray($resMoneyAdjusted);
932 $MoneyAdjusted=$rowMoneyAdjusted['MoneyAdjusted'];
934 else
935 {//Got just before the previous
936 //Fetch the LOWEST sequence_no till this session.
937 //Used maily in the case if primary/others pays once more.
938 $resSequence = sqlStatement("SELECT sequence_no from ar_activity where session_id ='$payment_id' and
939 pid ='$PId' and encounter ='$Encounter' order by sequence_no ");
940 $rowSequence = sqlFetchArray($resSequence);
941 $Sequence=$rowSequence['sequence_no'];
943 $resMoneyGot = sqlStatement("SELECT sum(pay_amount) as MoneyGot FROM ar_activity where
944 pid ='$PId' and code='$Code' and modifier='$Modifier' and encounter ='$Encounter'
945 and payer_type > 0 and payer_type <='$Ins' and sequence_no<'$Sequence'");
946 $rowMoneyGot = sqlFetchArray($resMoneyGot);
947 $MoneyGot=$rowMoneyGot['MoneyGot'];
949 $resMoneyAdjusted = sqlStatement("SELECT sum(adj_amount) as MoneyAdjusted FROM ar_activity where
950 pid ='$PId' and code='$Code' and modifier='$Modifier' and encounter ='$Encounter'
951 and payer_type <='$Ins' and sequence_no<'$Sequence' ");
952 $rowMoneyAdjusted = sqlFetchArray($resMoneyAdjusted);
953 $MoneyAdjusted=$rowMoneyAdjusted['MoneyAdjusted'];
955 //Stored in hidden so that can be used while restoring back the values.
956 $RemainderJS=$Fee-$Copay-$MoneyGot-$MoneyAdjusted;
958 $resPayment = sqlStatement("SELECT pay_amount from ar_activity where session_id ='$payment_id' and
959 pid ='$PId' and encounter ='$Encounter' and code='$Code' and modifier='$Modifier' and pay_amount>0");
960 $rowPayment = sqlFetchArray($resPayment);
961 $PaymentDB=$rowPayment['pay_amount']*1;
962 $PaymentDB=$PaymentDB == 0 ? '' : $PaymentDB;
964 $resPayment = sqlStatement("SELECT pay_amount from ar_activity where session_id ='$payment_id' and
965 pid ='$PId' and encounter ='$Encounter' and code='$Code' and modifier='$Modifier' and pay_amount<0");
966 $rowPayment = sqlFetchArray($resPayment);
967 $TakebackDB=$rowPayment['pay_amount']*-1;
968 $TakebackDB=$TakebackDB == 0 ? '' : $TakebackDB;
970 $resPayment = sqlStatement("SELECT adj_amount from ar_activity where session_id ='$payment_id' and
971 pid ='$PId' and encounter ='$Encounter' and code='$Code' and modifier='$Modifier' and adj_amount!=0");
972 $rowPayment = sqlFetchArray($resPayment);
973 $AdjAmountDB=$rowPayment['adj_amount']*1;
974 $AdjAmountDB=$AdjAmountDB == 0 ? '' : $AdjAmountDB;
976 $resPayment = sqlStatement("SELECT memo from ar_activity where session_id ='$payment_id' and
977 pid ='$PId' and encounter ='$Encounter' and code='$Code' and modifier='$Modifier' and memo like 'Deductable%'");
978 $rowPayment = sqlFetchArray($resPayment);
979 $DeductibleDB=$rowPayment['memo'];
980 $DeductibleDB=str_replace('Deductable $','',$DeductibleDB);
982 $resPayment = sqlStatement("SELECT follow_up,follow_up_note from ar_activity where session_id ='$payment_id' and
983 pid ='$PId' and encounter ='$Encounter' and code='$Code' and modifier='$Modifier' and follow_up = 'y'");
984 $rowPayment = sqlFetchArray($resPayment);
985 $FollowUpDB=$rowPayment['follow_up'];
986 $FollowUpReasonDB=$rowPayment['follow_up_note'];
988 $resPayment = sqlStatement("SELECT reason_code from ar_activity where session_id ='$payment_id' and
989 pid ='$PId' and encounter ='$Encounter' and code='$Code' and modifier='$Modifier'");
990 $rowPayment = sqlFetchArray($resPayment);
991 $ReasonCodeDB=$rowPayment['reason_code'];
993 if($Ins==1)
995 $AllowedDB=number_format($Fee-$AdjAmountDB,2);
997 else
999 $AllowedDB = 0;
1001 $AllowedDB=$AllowedDB == 0 ? '' : $AllowedDB;
1003 if($CountIndex==$TotalRows)
1005 $StringClass=' bottom left top ';
1007 else
1009 $StringClass=' left top ';
1012 if($Ins==1)
1014 $bgcolor='#ddddff';
1016 elseif($Ins==2)
1018 $bgcolor='#ffdddd';
1020 elseif($Ins==3)
1022 $bgcolor='#F2F1BC';
1024 elseif($Ins==0)
1026 $bgcolor='#AAFFFF';
1028 $paymenttot=$paymenttot+$PaymentDB;
1029 $adjamttot=$adjamttot+$AdjAmountDB;
1030 $deductibletot=$deductibletot+$DeductibleDB;
1031 $takebacktot=$takebacktot+$TakebackDB;
1032 $allowedtot=$allowedtot+$AllowedDB;
1034 <tr class="text" bgcolor='<?php echo $bgcolor; ?>' id="trCharges<?php echo $CountIndex; ?>">
1035 <td align="left" class="<?php echo $StringClass; ?>" ><a href="#" onClick="javascript:return DeletePaymentDistribution('<?php echo htmlspecialchars($payment_id.'_'.$PId.'_'.$Encounter.'_'.$Code.'_'.$Modifier); ?>');" ><img src="../pic/Delete.gif" border="0"/></a></td>
1036 <td align="left" class="<?php echo $StringClass; ?>" ><?php echo htmlspecialchars($NameDB); ?><input name="HiddenPId<?php echo $CountIndex; ?>" value="<?php echo htmlspecialchars($PId); ?>" type="hidden"/></td>
1037 <td align="left" class="<?php echo $StringClass; ?>" ><input name="HiddenIns<?php echo $CountIndex; ?>" id="HiddenIns<?php echo $CountIndex; ?>" value="<?php echo htmlspecialchars($Ins); ?>" type="hidden"/><?php echo generate_select_list("payment_ins$CountIndex", "payment_ins", "$Ins", "Insurance/Patient",'','','ActionOnInsPat("'.$CountIndex.'")'); ?></td>
1038 <td class="<?php echo $StringClass; ?>" ><?php echo htmlspecialchars($ServiceDate); ?></td>
1039 <td align="right" class="<?php echo $StringClass; ?>" ><input name="HiddenEncounter<?php echo $CountIndex; ?>" value="<?php echo htmlspecialchars($Encounter); ?>" type="hidden"/><?php echo htmlspecialchars($Encounter); ?></td>
1040 <td class="<?php echo $StringClass; ?>" ><input name="HiddenCode<?php echo $CountIndex; ?>" value="<?php echo htmlspecialchars($Code); ?>" type="hidden"/><?php echo htmlspecialchars($Code.$ModifierString); ?><input name="HiddenModifier<?php echo $CountIndex; ?>" value="<?php echo htmlspecialchars($Modifier); ?>" type="hidden"/></td>
1041 <td align="right" class="<?php echo $StringClass; ?>" ><input name="HiddenChargeAmount<?php echo $CountIndex; ?>" id="HiddenChargeAmount<?php echo $CountIndex; ?>" value="<?php echo htmlspecialchars($Fee); ?>" type="hidden"/><?php echo htmlspecialchars($Fee); ?></td>
1042 <td align="right" class="<?php echo $StringClass; ?>" ><input name="HiddenCopayAmount<?php echo $CountIndex; ?>" id="HiddenCopayAmount<?php echo $CountIndex; ?>" value="<?php echo htmlspecialchars($Copay); ?>" type="hidden"/><?php echo htmlspecialchars(number_format($Copay,2)); ?></td>
1043 <td align="right" id="RemainderTd<?php echo $CountIndex; ?>" class="<?php echo $StringClass; ?>" ><?php echo htmlspecialchars(round($Remainder,2)); ?></td>
1044 <input name="HiddenRemainderTd<?php echo $CountIndex; ?>" id="HiddenRemainderTd<?php echo $CountIndex; ?>" value="<?php echo htmlspecialchars(round($RemainderJS,2)); ?>" type="hidden"/>
1045 <td class="<?php echo $StringClass; ?>" ><input name="Allowed<?php echo $CountIndex; ?>" id="Allowed<?php echo $CountIndex; ?>" onKeyDown="PreventIt(event)" autocomplete="off" value="<?php echo htmlspecialchars($AllowedDB); ?>" onChange="ValidateNumeric(this);ScreenAdjustment(this,<?php echo $CountIndex; ?>);UpdateTotalValues(1,<?php echo $TotalRows; ?>,'Allowed','allowtotal');UpdateTotalValues(1,<?php echo $TotalRows; ?>,'Payment','paymenttotal');UpdateTotalValues(1,<?php echo $TotalRows; ?>,'AdjAmount','AdjAmounttotal');RestoreValues(<?php echo $CountIndex; ?>)" type="text" style="width:60px;text-align:right; font-size:12px" /></td>
1046 <td class="<?php echo $StringClass; ?>" ><input type="text" name="Payment<?php echo $CountIndex; ?>" onKeyDown="PreventIt(event)" autocomplete="off" id="Payment<?php echo $CountIndex; ?>" value="<?php echo htmlspecialchars($PaymentDB); ?>" onChange="ValidateNumeric(this);ScreenAdjustment(this,<?php echo $CountIndex; ?>);UpdateTotalValues(1,<?php echo $TotalRows; ?>,'Payment','paymenttotal');RestoreValues(<?php echo $CountIndex; ?>)" style="width:60px;text-align:right; font-size:12px" /></td>
1047 <td class="<?php echo $StringClass; ?>" ><input name="AdjAmount<?php echo $CountIndex; ?>" onKeyDown="PreventIt(event)" autocomplete="off" id="AdjAmount<?php echo $CountIndex; ?>" value="<?php echo htmlspecialchars($AdjAmountDB); ?>" onChange="ValidateNumeric(this);ScreenAdjustment(this,<?php echo $CountIndex; ?>);UpdateTotalValues(1,<?php echo $TotalRows; ?>,'AdjAmount','AdjAmounttotal');RestoreValues(<?php echo $CountIndex; ?>)" type="text" style="width:70px;text-align:right; font-size:12px" /></td>
1048 <td class="<?php echo $StringClass; ?>" ><input name="Deductible<?php echo $CountIndex; ?>" id="Deductible<?php echo $CountIndex; ?>" onKeyDown="PreventIt(event)" onChange="ValidateNumeric(this);UpdateTotalValues(1,<?php echo $TotalRows; ?>,'Deductible','deductibletotal');" value="<?php echo htmlspecialchars($DeductibleDB); ?>" autocomplete="off" type="text" style="width:60px;text-align:right; font-size:12px" /></td>
1049 <td class="<?php echo $StringClass; ?>" ><input name="Takeback<?php echo $CountIndex; ?>" onKeyDown="PreventIt(event)" autocomplete="off" id="Takeback<?php echo $CountIndex; ?>" value="<?php echo htmlspecialchars($TakebackDB); ?>" onChange="ValidateNumeric(this);ScreenAdjustment(this,<?php echo $CountIndex; ?>);UpdateTotalValues(1,<?php echo $TotalRows; ?>,'Takeback','takebacktotal');RestoreValues(<?php echo $CountIndex; ?>)" type="text" style="width:60px;text-align:right; font-size:12px" /></td>
1050 <td align="left" class="<?php echo $StringClass; ?>" ><input name="HiddenReasonCode<?php echo $CountIndex; ?>" id="HiddenReasonCode<?php echo $CountIndex; ?>" value="<?php echo htmlspecialchars($ReasonCodeDB); ?>" type="hidden"/><?php echo generate_select_list( "ReasonCode$CountIndex", "msp_remit_codes", "$ReasonCodeDB", "MSP Code" ); ?></td>
1051 <td align="center" class="<?php echo $StringClass; ?>" ><input type="checkbox" id="FollowUp<?php echo $CountIndex; ?>" name="FollowUp<?php echo $CountIndex; ?>" value="y" onClick="ActionFollowUp(<?php echo $CountIndex; ?>)" <?php echo $FollowUpDB=='y' ? ' checked ' : ''; ?> /></td>
1052 <td class="<?php echo $StringClass; ?> right" ><input onKeyDown="PreventIt(event)" id="FollowUpReason<?php echo $CountIndex; ?>" name="FollowUpReason<?php echo $CountIndex; ?>" <?php echo $FollowUpDB=='y' ? '' : ' readonly '; ?> type="text" value="<?php echo htmlspecialchars($FollowUpReasonDB); ?>" style="width:110px;font-size:12px" /></td>
1053 </tr>
1054 <?php
1057 }//while ($RowSearch = sqlFetchArray($ResultSearch))
1059 <?php
1060 }//if(sqlNumRows($ResultSearch)>0)
1062 }while ($RowSearchSub = sqlFetchArray($ResultSearchSub));
1063 if($Table=='yes')
1066 <tr class="text">
1067 <td align="left" colspan="9">&nbsp;</td>
1068 <td class="left bottom" bgcolor="#6699FF" id="allowtotal" align="right" ><?php echo htmlspecialchars(number_format($allowedtot,2)); ?></td>
1069 <td class="left bottom" bgcolor="#6699FF" id="paymenttotal" align="right" ><?php echo htmlspecialchars(number_format($paymenttot,2)); ?></td>
1070 <td class="left bottom" bgcolor="#6699FF" id="AdjAmounttotal" align="right" ><?php echo htmlspecialchars(number_format($adjamttot,2)); ?></td>
1071 <td class="left bottom" bgcolor="#6699FF" id="deductibletotal" align="right"><?php echo htmlspecialchars(number_format($deductibletot,2)); ?></td>
1072 <td class="left bottom right" bgcolor="#6699FF" id="takebacktotal" align="right"><?php echo htmlspecialchars(number_format($takebacktot,2)); ?></td>
1073 <td align="center">&nbsp;</td>
1074 <td align="center">&nbsp;</td>
1075 </tr>
1076 </table>
1077 <?php
1080 <?php
1082 echo '<br/>';
1084 }//if($RowSearchSub = sqlFetchArray($ResultSearchSub))
1085 ?> </td>
1086 </tr>
1087 <tr>
1088 <td colspan="13" align="left" >
1089 <?php
1090 require_once("payment_pat_sel.inc.php"); //Patient ajax section and listing of charges.
1092 </td>
1093 </tr>
1094 <tr>
1095 <td colspan="13" align="left" >
1096 <table border="0" cellspacing="0" cellpadding="0" width="217" align="center">
1097 <tr height="5">
1098 <td ></td>
1099 <td ></td>
1100 <td></td>
1101 </tr>
1102 <tr>
1103 <td width="110"><a href="#" onClick="javascript:return ModifyPayments();" class="css_button"><span><?php echo htmlspecialchars( xl('Modify Payments'), ENT_QUOTES);?></span></a>
1104 </td>
1105 <td width="107"><a href="#" onClick="javascript:return FinishPayments();" class="css_button"><span><?php echo htmlspecialchars( xl('Finish Payments'), ENT_QUOTES);?></span></a>
1106 </td>
1107 </tr>
1108 </table>
1110 <?php
1111 }//if($payment_id*1>0)
1112 ?> </td>
1113 </tr>
1114 </table>
1115 </td></tr></table>
1117 <input type="hidden" name="hidden_patient_code" id="hidden_patient_code" value="<?php echo htmlspecialchars($hidden_patient_code);?>"/>
1118 <input type='hidden' name='mode' id='mode' value='' />
1119 <input type='hidden' name='ajax_mode' id='ajax_mode' value='' />
1120 <input type="hidden" name="after_value" id="after_value" value="<?php echo htmlspecialchars($_POST["mode"]);?>"/>
1121 <input type="hidden" name="payment_id" id="payment_id" value="<?php echo htmlspecialchars($payment_id);?>"/>
1122 <input type="hidden" name="hidden_type_code" id="hidden_type_code" value="<?php echo htmlspecialchars($TypeCode);?>"/>
1123 <input type='hidden' name='global_amount' id='global_amount' value='' />
1124 <input type='hidden' name='DeletePaymentDistributionId' id='DeletePaymentDistributionId' value='' />
1125 <input type="hidden" name="ActionStatus" id="ActionStatus" value="<?php echo htmlspecialchars($Message);?>"/>
1126 <input type='hidden' name='CountIndexAbove' id='CountIndexAbove' value='<?php echo htmlspecialchars($CountIndexAbove*1);?>' />
1127 <input type='hidden' name='CountIndexBelow' id='CountIndexBelow' value='<?php echo htmlspecialchars($CountIndexBelow*1);?>' />
1128 <input type="hidden" name="ParentPage" id="ParentPage" value="<?php echo htmlspecialchars($_REQUEST['ParentPage']);?>"/>
1129 </form>
1131 </body>
1132 </html>