Left menu navigations bug fixes:
[openemr.git] / interface / billing / edit_payment.php
blob86b72d7be66adc92152827b2d59f9981bfb24abf
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 "' where session_id ='$payment_id' and pid ='" . trim(formData("HiddenPId$CountRow" )) .
168 "' and encounter ='" . trim(formData("HiddenEncounter$CountRow" )) .
169 "' and code ='" . trim(formData("HiddenCode$CountRow" )) .
170 "' and modifier ='" . trim(formData("HiddenModifier$CountRow" )) .
171 "' and pay_amount>0");
173 else
175 sqlStatement("insert into ar_activity set " .
176 "pid = '" . trim(formData("HiddenPId$CountRow" )) .
177 "', encounter = '" . trim(formData("HiddenEncounter$CountRow" )) .
178 "', code = '" . trim(formData("HiddenCode$CountRow" )) .
179 "', modifier = '" . trim(formData("HiddenModifier$CountRow" )) .
180 "', payer_type = '" . trim(formData("HiddenIns$CountRow" )) .
181 "', post_time = '" . trim($created_time ) .
182 "', post_user = '" . trim($user_id ) .
183 "', session_id = '" . trim(formData('payment_id')) .
184 "', modified_time = '" . trim($created_time ) .
185 "', pay_amount = '" . trim(formData("Payment$CountRow" )) .
186 "', adj_amount = '" . 0 .
187 "', account_code = '" . "$AccountCode" .
188 "'");
191 else
193 sqlStatement("delete from ar_activity " .
194 " where session_id ='$payment_id' and pid ='" . trim(formData("HiddenPId$CountRow" )) .
195 "' and encounter ='" . trim(formData("HiddenEncounter$CountRow" )) .
196 "' and code ='" . trim(formData("HiddenCode$CountRow" )) .
197 "' and modifier ='" . trim(formData("HiddenModifier$CountRow" )) .
198 "' and pay_amount>0");
200 //==============================================================================================================================
201 if (isset($_POST["AdjAmount$CountRow"]) && $_POST["AdjAmount$CountRow"]*1!=0)
203 if(trim(formData('type_name' ))=='insurance')
205 $AdjustString="Ins adjust Ins".trim(formData("HiddenIns$CountRow" ));
206 $AccountCode="IA";
208 elseif(trim(formData('type_name' ))=='patient')
210 $AdjustString="Pt adjust";
211 $AccountCode="PA";
213 $resPayment = sqlStatement("SELECT * from ar_activity " .
214 " where session_id ='$payment_id' and pid ='" . trim(formData("HiddenPId$CountRow" )) .
215 "' and encounter ='" . trim(formData("HiddenEncounter$CountRow" )) .
216 "' and code ='" . trim(formData("HiddenCode$CountRow" )) .
217 "' and modifier ='" . trim(formData("HiddenModifier$CountRow" )) .
218 "' and adj_amount!=0");
219 if(sqlNumRows($resPayment)>0)
221 sqlStatement("update ar_activity set " .
222 " post_user = '" . trim($user_id ) .
223 "', modified_time = '" . trim($created_time ) .
224 "', adj_amount = '" . trim(formData("AdjAmount$CountRow" )) .
225 "', memo = '" . "$AdjustString" .
226 "', account_code = '" . "$AccountCode" .
227 "', payer_type = '" . trim(formData("HiddenIns$CountRow" )) .
228 "' where session_id ='$payment_id' and pid ='" . trim(formData("HiddenPId$CountRow" )) .
229 "' and encounter ='" . trim(formData("HiddenEncounter$CountRow" )) .
230 "' and code ='" . trim(formData("HiddenCode$CountRow" )) .
231 "' and modifier ='" . trim(formData("HiddenModifier$CountRow" )) .
232 "' and adj_amount!=0");
234 else
236 sqlStatement("insert into ar_activity set " .
237 "pid = '" . trim(formData("HiddenPId$CountRow" )) .
238 "', encounter = '" . trim(formData("HiddenEncounter$CountRow" )) .
239 "', code = '" . trim(formData("HiddenCode$CountRow" )) .
240 "', modifier = '" . trim(formData("HiddenModifier$CountRow" )) .
241 "', payer_type = '" . trim(formData("HiddenIns$CountRow" )) .
242 "', post_time = '" . trim($created_time ) .
243 "', post_user = '" . trim($user_id ) .
244 "', session_id = '" . trim(formData('payment_id')) .
245 "', modified_time = '" . trim($created_time ) .
246 "', pay_amount = '" . 0 .
247 "', adj_amount = '" . trim(formData("AdjAmount$CountRow" )) .
248 "', memo = '" . "$AdjustString" .
249 "', account_code = '" . "$AccountCode" .
250 "'");
254 else
256 sqlStatement("delete from ar_activity " .
257 " where session_id ='$payment_id' and pid ='" . trim(formData("HiddenPId$CountRow" )) .
258 "' and encounter ='" . trim(formData("HiddenEncounter$CountRow" )) .
259 "' and code ='" . trim(formData("HiddenCode$CountRow" )) .
260 "' and modifier ='" . trim(formData("HiddenModifier$CountRow" )) .
261 "' and adj_amount!=0");
263 //==============================================================================================================================
264 if (isset($_POST["Deductible$CountRow"]) && $_POST["Deductible$CountRow"]*1>0)
266 $resPayment = sqlStatement("SELECT * from ar_activity " .
267 " where session_id ='$payment_id' and pid ='" . trim(formData("HiddenPId$CountRow" )) .
268 "' and encounter ='" . trim(formData("HiddenEncounter$CountRow" )) .
269 "' and code ='" . trim(formData("HiddenCode$CountRow" )) .
270 "' and modifier ='" . trim(formData("HiddenModifier$CountRow" )) .
271 "' and memo like 'Deductable%'");
272 if(sqlNumRows($resPayment)>0)
274 sqlStatement("update ar_activity set " .
275 " post_user = '" . trim($user_id ) .
276 "', modified_time = '" . trim($created_time ) .
277 "', memo = '" . "Deductable $".trim(formData("Deductible$CountRow" )) .
278 "', account_code = '" . "Deduct" .
279 "', payer_type = '" . trim(formData("HiddenIns$CountRow" )) .
280 "' where session_id ='$payment_id' and pid ='" . trim(formData("HiddenPId$CountRow" )) .
281 "' and encounter ='" . trim(formData("HiddenEncounter$CountRow" )) .
282 "' and code ='" . trim(formData("HiddenCode$CountRow" )) .
283 "' and modifier ='" . trim(formData("HiddenModifier$CountRow" )) .
284 "' and memo like 'Deductable%'");
286 else
288 sqlStatement("insert into ar_activity set " .
289 "pid = '" . trim(formData("HiddenPId$CountRow" )) .
290 "', encounter = '" . trim(formData("HiddenEncounter$CountRow" )) .
291 "', code = '" . trim(formData("HiddenCode$CountRow" )) .
292 "', modifier = '" . trim(formData("HiddenModifier$CountRow" )) .
293 "', payer_type = '" . trim(formData("HiddenIns$CountRow" )) .
294 "', post_time = '" . trim($created_time ) .
295 "', post_user = '" . trim($user_id ) .
296 "', session_id = '" . trim(formData('payment_id')) .
297 "', modified_time = '" . trim($created_time ) .
298 "', pay_amount = '" . 0 .
299 "', adj_amount = '" . 0 .
300 "', memo = '" . "Deductable $".trim(formData("Deductible$CountRow" )) .
301 "', account_code = '" . "Deduct" .
302 "'");
305 else
307 sqlStatement("delete from ar_activity " .
308 " where session_id ='$payment_id' and pid ='" . trim(formData("HiddenPId$CountRow" )) .
309 "' and encounter ='" . trim(formData("HiddenEncounter$CountRow" )) .
310 "' and code ='" . trim(formData("HiddenCode$CountRow" )) .
311 "' and modifier ='" . trim(formData("HiddenModifier$CountRow" )) .
312 "' and memo like 'Deductable%'");
314 //==============================================================================================================================
315 if (isset($_POST["Takeback$CountRow"]) && $_POST["Takeback$CountRow"]*1>0)
317 $resPayment = sqlStatement("SELECT * from ar_activity " .
318 " where session_id ='$payment_id' and pid ='" . trim(formData("HiddenPId$CountRow" )) .
319 "' and encounter ='" . trim(formData("HiddenEncounter$CountRow" )) .
320 "' and code ='" . trim(formData("HiddenCode$CountRow" )) .
321 "' and modifier ='" . trim(formData("HiddenModifier$CountRow" )) .
322 "' and pay_amount < 0");
323 if(sqlNumRows($resPayment)>0)
325 sqlStatement("update ar_activity set " .
326 " post_user = '" . trim($user_id ) .
327 "', modified_time = '" . trim($created_time ) .
328 "', pay_amount = '" . trim(formData("Takeback$CountRow" ))*-1 .
329 "', account_code = '" . "Takeback" .
330 "', payer_type = '" . trim(formData("HiddenIns$CountRow" )) .
331 "' where session_id ='$payment_id' and pid ='" . trim(formData("HiddenPId$CountRow" )) .
332 "' and encounter ='" . trim(formData("HiddenEncounter$CountRow" )) .
333 "' and code ='" . trim(formData("HiddenCode$CountRow" )) .
334 "' and modifier ='" . trim(formData("HiddenModifier$CountRow" )) .
335 "' and pay_amount < 0");
337 else
339 sqlStatement("insert into ar_activity set " .
340 "pid = '" . trim(formData("HiddenPId$CountRow" )) .
341 "', encounter = '" . trim(formData("HiddenEncounter$CountRow" )) .
342 "', code = '" . trim(formData("HiddenCode$CountRow" )) .
343 "', modifier = '" . trim(formData("HiddenModifier$CountRow" )) .
344 "', payer_type = '" . trim(formData("HiddenIns$CountRow" )) .
345 "', post_time = '" . trim($created_time ) .
346 "', post_user = '" . trim($user_id ) .
347 "', session_id = '" . trim(formData('payment_id')) .
348 "', modified_time = '" . trim($created_time ) .
349 "', pay_amount = '" . trim(formData("Takeback$CountRow" ))*-1 .
350 "', adj_amount = '" . 0 .
351 "', account_code = '" . "Takeback" .
352 "'");
355 else
357 sqlStatement("delete from ar_activity " .
358 " where session_id ='$payment_id' and pid ='" . trim(formData("HiddenPId$CountRow" )) .
359 "' and encounter ='" . trim(formData("HiddenEncounter$CountRow" )) .
360 "' and code ='" . trim(formData("HiddenCode$CountRow" )) .
361 "' and modifier ='" . trim(formData("HiddenModifier$CountRow" )) .
362 "' and pay_amount < 0");
364 //==============================================================================================================================
365 if (isset($_POST["FollowUp$CountRow"]) && $_POST["FollowUp$CountRow"]=='y')
367 $resPayment = sqlStatement("SELECT * from ar_activity " .
368 " where session_id ='$payment_id' and pid ='" . trim(formData("HiddenPId$CountRow" )) .
369 "' and encounter ='" . trim(formData("HiddenEncounter$CountRow" )) .
370 "' and code ='" . trim(formData("HiddenCode$CountRow" )) .
371 "' and modifier ='" . trim(formData("HiddenModifier$CountRow" )) .
372 "' and follow_up ='y'");
373 if(sqlNumRows($resPayment)>0)
375 sqlStatement("update ar_activity set " .
376 " post_user = '" . trim($user_id ) .
377 "', modified_time = '" . trim($created_time ) .
378 "', follow_up = '" . "y" .
379 "', follow_up_note = '" . trim(formData("FollowUpReason$CountRow" )) .
380 "', payer_type = '" . trim(formData("HiddenIns$CountRow" )) .
381 "' where session_id ='$payment_id' and pid ='" . trim(formData("HiddenPId$CountRow" )) .
382 "' and encounter ='" . trim(formData("HiddenEncounter$CountRow" )) .
383 "' and code ='" . trim(formData("HiddenCode$CountRow" )) .
384 "' and modifier ='" . trim(formData("HiddenModifier$CountRow" )) .
385 "' and follow_up ='y'");
387 else
389 sqlStatement("insert into ar_activity set " .
390 "pid = '" . trim(formData("HiddenPId$CountRow" )) .
391 "', encounter = '" . trim(formData("HiddenEncounter$CountRow" )) .
392 "', code = '" . trim(formData("HiddenCode$CountRow" )) .
393 "', modifier = '" . trim(formData("HiddenModifier$CountRow" )) .
394 "', payer_type = '" . trim(formData("HiddenIns$CountRow" )) .
395 "', post_time = '" . trim($created_time ) .
396 "', post_user = '" . trim($user_id ) .
397 "', session_id = '" . trim(formData('payment_id')) .
398 "', modified_time = '" . trim($created_time ) .
399 "', pay_amount = '" . 0 .
400 "', adj_amount = '" . 0 .
401 "', follow_up = '" . "y" .
402 "', follow_up_note = '" . trim(formData("FollowUpReason$CountRow" )) .
403 "'");
406 else
408 sqlStatement("delete from ar_activity " .
409 " where session_id ='$payment_id' and pid ='" . trim(formData("HiddenPId$CountRow" )) .
410 "' and encounter ='" . trim(formData("HiddenEncounter$CountRow" )) .
411 "' and code ='" . trim(formData("HiddenCode$CountRow" )) .
412 "' and modifier ='" . trim(formData("HiddenModifier$CountRow" )) .
413 "' and follow_up ='y'");
415 //==============================================================================================================================
417 else
418 break;
420 //=========
421 //INSERTION of new entries,continuation of modification.
422 //=========
423 for($CountRow=$CountIndexAbove+1;$CountRow<=$CountIndexAbove+$CountIndexBelow;$CountRow++)
425 if (isset($_POST["HiddenEncounter$CountRow"]))
427 DistributionInsert($CountRow,$created_time,$user_id);
429 else
430 break;
432 if($_REQUEST['global_amount']=='yes')
433 sqlStatement("update ar_session set global_amount=".trim(formData("HidUnappliedAmount" ))*1 ." where session_id ='$payment_id'");
434 if($_POST["mode"]=="FinishPayments")
436 $Message='Finish';
438 $_POST["mode"] = "searchdatabase";
439 $Message='Modify';
442 //==============================================================================
443 //Search Code
444 //===============================================================================
445 $payment_id=$payment_id*1 > 0 ? $payment_id : $_REQUEST['payment_id'];
446 $ResultSearchSub = sqlStatement("SELECT distinct encounter,code,modifier, pid from ar_activity where session_id ='$payment_id' order by pid,encounter,code,modifier");
447 //==============================================================================
448 $DateFormat=DateFormatRead();
449 //==============================================================================
450 //===============================================================================
453 <html>
454 <head>
455 <?php if (function_exists('html_header_show')) html_header_show(); ?>
457 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
459 <!-- supporting javascript code -->
461 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/dialog.js"></script>
465 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
466 <link rel="stylesheet" type="text/css" href="../../library/js/fancybox/jquery.fancybox-1.2.6.css" media="screen" />
467 <style type="text/css">@import url(../../library/dynarch_calendar.css);</style>
468 <script type="text/javascript" src="../../library/textformat.js"></script>
469 <script type="text/javascript" src="../../library/dynarch_calendar.js"></script>
470 <?php include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?>
471 <script type="text/javascript" src="../../library/dynarch_calendar_setup.js"></script>
472 <script type="text/javascript" src="../../library/dialog.js"></script>
473 <script type="text/javascript" src="../../library/js/jquery.1.3.2.js"></script>
474 <script type="text/javascript" src="../../library/js/fancybox/jquery.fancybox-1.2.6.js"></script>
475 <script language='JavaScript'>
476 var mypcc = '1';
477 </script>
478 <?php include_once("{$GLOBALS['srcdir']}/payment_jav.inc.php"); ?>
479 <?php include_once("{$GLOBALS['srcdir']}/ajax/payment_ajax_jav.inc.php"); ?>
480 <script type="text/javascript" src="../../library/js/common.js"></script>
481 <script LANGUAGE="javascript" TYPE="text/javascript">
482 function ModifyPayments()
483 {//Used while modifying the allocation
484 if(!FormValidations())//FormValidations contains the form checks
486 return false;
488 if(CompletlyBlankAbove())//The distribution rows already in the database are checked.
490 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) ?>")
491 return false;
493 if(!CheckPayingEntityAndDistributionPostFor())//Ensures that Insurance payment is distributed under Ins1,Ins2,Ins3 and Patient paymentat under Pat.
495 return false;
497 if(CompletlyBlankBelow())//The newly added distribution rows are checked.
499 alert("<?php echo htmlspecialchars( xl('Fill any of the Below Row.'), ENT_QUOTES) ?>")
500 return false;
502 PostValue=CheckUnappliedAmount();//Decides TdUnappliedAmount >0, or <0 or =0
503 if(PostValue==1)
505 alert("<?php echo htmlspecialchars( xl('Cannot Modify Payments.Undistributed is Negative.'), ENT_QUOTES) ?>")
506 return false;
508 if(confirm("<?php echo htmlspecialchars( xl('Would you like to Modify Payments?'), ENT_QUOTES) ?>"))
510 document.getElementById('mode').value='ModifyPayments';
511 top.restoreSession();
512 document.forms[0].submit();
514 else
515 return false;
517 function FinishPayments()
519 if(!FormValidations())//FormValidations contains the form checks
521 return false;
523 if(CompletlyBlankAbove())//The distribution rows already in the database are checked.
525 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) ?>")
526 return false;
528 if(!CheckPayingEntityAndDistributionPostFor())//Ensures that Insurance payment is distributed under Ins1,Ins2,Ins3 and Patient paymentat under Pat.
530 return false;
532 if(CompletlyBlankBelow())//The newly added distribution rows are checked.
534 alert("<?php echo htmlspecialchars( xl('Fill any of the Below Row.'), ENT_QUOTES) ?>")
535 return false;
537 PostValue=CheckUnappliedAmount();//Decides TdUnappliedAmount >0, or <0 or =0
538 if(PostValue==1)
540 alert("<?php echo htmlspecialchars( xl('Cannot Modify Payments.UNDISTRIBUTED is Negative.'), ENT_QUOTES) ?>")
541 return false;
543 if(PostValue==2)
545 if(confirm("<?php echo htmlspecialchars( xl('Would you like to Modify and Finish Payments?'), ENT_QUOTES) ?>"))
547 UnappliedAmount=document.getElementById('TdUnappliedAmount').innerHTML*1;
548 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) ?>"))
550 document.getElementById('mode').value='FinishPayments';
551 document.getElementById('global_amount').value='yes';
552 top.restoreSession();
553 document.forms[0].submit();
555 else
557 document.getElementById('mode').value='FinishPayments';
558 top.restoreSession();
559 document.forms[0].submit();
562 else
563 return false;
565 else
567 if(confirm("<?php echo htmlspecialchars( xl('Would you like to Modify and Finish Payments?'), ENT_QUOTES) ?>"))
569 document.getElementById('mode').value='FinishPayments';
570 top.restoreSession();
571 document.forms[0].submit();
573 else
574 return false;
578 function CompletlyBlankAbove()
579 {//The distribution rows already in the database are checked.
580 //It is not allowed to be made completly empty.If needed delete option need to be used.
581 CountIndexAbove=document.getElementById('CountIndexAbove').value*1;
582 for(RowCount=1;RowCount<=CountIndexAbove;RowCount++)
584 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)
586 return true;
589 return false;
591 function CompletlyBlankBelow()
592 {//The newly added distribution rows are checked.
593 //It is not allowed to be made completly empty.
594 CountIndexAbove=document.getElementById('CountIndexAbove').value*1;
595 CountIndexBelow=document.getElementById('CountIndexBelow').value*1;
596 if(CountIndexBelow==0)
597 return false;
598 for(RowCount=CountIndexAbove+1;RowCount<=CountIndexAbove+CountIndexBelow;RowCount++)
600 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)
604 else
605 return false;
607 return true;
609 function OnloadAction()
610 {//Displays message while loading after some action.
611 after_value=document.getElementById('ActionStatus').value;
612 if(after_value=='Delete')
614 alert("<?php echo htmlspecialchars( xl('Successfully Deleted'), ENT_QUOTES) ?>")
615 return true;
617 if(after_value=='Modify' || after_value=='Finish')
619 alert("<?php echo htmlspecialchars( xl('Successfully Modified'), ENT_QUOTES) ?>")
620 return true;
622 after_value=document.getElementById('after_value').value;
623 payment_id=document.getElementById('payment_id').value;
624 if(after_value=='distribute')
627 else if(after_value=='new_payment')
629 if(document.getElementById('TablePatientPortion'))
631 document.getElementById('TablePatientPortion').style.display='none';
633 if(confirm("<?php echo htmlspecialchars( xl('Successfully Saved.Would you like to Distribute?'), ENT_QUOTES) ?>"))
635 if(document.getElementById('TablePatientPortion'))
637 document.getElementById('TablePatientPortion').style.display='';
643 function DeletePaymentDistribution(DeleteId)
644 {//Confirms deletion of payment distribution.
645 if(confirm("<?php echo htmlspecialchars( xl('Would you like to Delete Payment Distribution?'), ENT_QUOTES) ?>"))
647 document.getElementById('mode').value='DeletePaymentDistribution';
648 document.getElementById('DeletePaymentDistributionId').value=DeleteId;
649 top.restoreSession();
650 document.forms[0].submit();
652 else
653 return false;
655 //========================================================================================
656 </script>
657 <script language="javascript" type="text/javascript">
658 document.onclick=HideTheAjaxDivs;
659 </script>
660 <style>
661 .class1{width:125px;}
662 .class2{width:250px;}
663 .class3{width:100px;}
664 .bottom{border-bottom:1px solid black;}
665 .top{border-top:1px solid black;}
666 .left{border-left:1px solid black;}
667 .right{border-right:1px solid black;}
668 #ajax_div_insurance {
669 position: absolute;
670 z-index:10;
672 left: 20px;
673 top: 300px;
675 background-color: #FBFDD0;
676 border: 1px solid #ccc;
677 padding: 10px;
679 #ajax_div_patient {
680 position: absolute;
681 z-index:10;
683 left: 20px;
684 top: 300px;
686 background-color: #FBFDD0;
687 border: 1px solid #ccc;
688 padding: 10px;
690 </style>
691 <link rel="stylesheet" href="<?php echo $css_header; ?>" type="text/css">
692 </head>
693 <body class="body_top" onLoad="OnloadAction()" >
694 <form name='new_payment' method='post' action="edit_payment.php" onsubmit='
695 <?php
696 if($payment_id*1==0)
699 top.restoreSession();return SavePayment();
700 <?php
702 else
705 return false;
706 <?php
709 ' style="display:inline" >
710 <table width="1024" border="0" cellspacing="0" cellpadding="0">
711 <?php
712 if($_REQUEST['ParentPage']=='new_payment')
715 <tr>
716 <td colspan="3" align="left"><b><?php echo htmlspecialchars( xl('Payments'), ENT_QUOTES) ?></b></td>
717 </tr>
718 <tr height="15">
719 <td colspan="3" align="left" ></td>
720 </tr>
721 <tr>
722 <td colspan="3" align="left">
723 <ul class="tabNav">
724 <li class='current'><a href='new_payment.php'><?php echo htmlspecialchars( xl('New Payment'), ENT_QUOTES) ?></a></li>
725 <li><a href='search_payments.php'><?php echo htmlspecialchars( xl('Search Payment'), ENT_QUOTES) ?></a></li>
726 <li><a href='era_payments.php'><?php echo htmlspecialchars( xl('ERA Posting'), ENT_QUOTES) ?></a></li>
727 </ul> </td>
728 </tr>
729 <?php
731 else
734 <tr height="5">
735 <td colspan="3" align="left" ></td>
736 </tr>
737 <?php
740 <tr>
741 <td colspan="3" align="left" >
743 <?php
744 if($payment_id*1>0)
747 <?php
748 require_once("payment_master.inc.php"); //Check/cash details are entered here.
750 <?php
753 </td>
754 </tr>
755 </table>
759 <?php
760 if($payment_id*1>0)
761 {//Distribution rows already in the database are displayed.
764 <table width="1024" border="0" cellspacing="0" cellpadding="10" bgcolor="#DEDEDE"><tr><td>
765 <table width="1004" border="0" cellspacing="0" cellpadding="0">
767 <tr>
768 <td colspan="13" align="left" >
770 <?php //
771 $resCount = sqlStatement("SELECT distinct encounter,code,modifier from ar_activity where session_id ='$payment_id' ");
772 $TotalRows=sqlNumRows($resCount);
773 $CountPatient=0;
774 $CountIndex=0;
775 $CountIndexAbove=0;
776 $paymenttot=0;
777 $adjamttot=0;
778 $deductibletot=0;
779 $takebacktot=0;
780 $allowedtot=0;
781 if($RowSearchSub = sqlFetchArray($ResultSearchSub))
785 $CountPatient++;
786 $PId=$RowSearchSub['pid'];
787 $EncounterMaster=$RowSearchSub['encounter'];
788 $CodeMaster=$RowSearchSub['code'];
789 $ModifierMaster=$RowSearchSub['modifier'];
790 $res = sqlStatement("SELECT fname,lname,mname FROM patient_data where pid ='$PId'");
791 $row = sqlFetchArray($res);
792 $fname=$row['fname'];
793 $lname=$row['lname'];
794 $mname=$row['mname'];
795 $NameDB=$lname.' '.$fname.' '.$mname;
796 $ResultSearch = sqlStatement("SELECT billing.id,last_level_closed,billing.encounter,form_encounter.`date`,billing.code,billing.modifier,fee
797 FROM billing ,form_encounter
798 where billing.encounter=form_encounter.encounter and billing.pid=form_encounter.pid and
799 code_type!='ICD9' and code_type!='COPAY' and billing.activity!=0 and
800 form_encounter.pid ='$PId' and billing.pid ='$PId' and billing.encounter ='$EncounterMaster'
801 and billing.code ='$CodeMaster'
802 and billing.modifier ='$ModifierMaster'
803 ORDER BY form_encounter.`date`,form_encounter.encounter,billing.code,billing.modifier");
804 if(sqlNumRows($ResultSearch)>0)
806 if($CountPatient==1)
808 $Table='yes';
810 <table width="1004" border="0" cellpadding="0" cellspacing="0" align="center" id="TableDistributePortion">
811 <tr class="text" bgcolor="#dddddd">
812 <td width="25" class="left top" >&nbsp;</td>
813 <td width="144" class="left top" ><?php echo htmlspecialchars( xl('Patient Name'), ENT_QUOTES) ?></td>
814 <td width="55" class="left top" ><?php echo htmlspecialchars( xl('Post For'), ENT_QUOTES) ?></td>
815 <td width="70" class="left top" ><?php echo htmlspecialchars( xl('Srv Date'), ENT_QUOTES) ?></td>
816 <td width="50" class="left top" ><?php echo htmlspecialchars( xl('Encnter'), ENT_QUOTES) ?></td>
817 <td width="65" class="left top" ><?php echo htmlspecialchars( xl('CPT Code'), ENT_QUOTES) ?></td>
818 <td width="50" class="left top" ><?php echo htmlspecialchars( xl('Charge'), ENT_QUOTES) ?></td>
819 <td width="40" class="left top" ><?php echo htmlspecialchars( xl('Copay'), ENT_QUOTES) ?></td>
820 <td width="40" class="left top" ><?php echo htmlspecialchars( xl('Remdr'), ENT_QUOTES) ?></td>
821 <td width="60" class="left top" ><?php echo htmlspecialchars( xl('Allowed(c)'), ENT_QUOTES) ?></td><!-- (c) means it is calculated.Not stored one. -->
822 <td width="60" class="left top" ><?php echo htmlspecialchars( xl('Payment'), ENT_QUOTES) ?></td>
823 <td width="70" class="left top" ><?php echo htmlspecialchars( xl('Adj Amount'), ENT_QUOTES) ?></td>
824 <td width="60" class="left top" ><?php echo htmlspecialchars( xl('Deductible'), ENT_QUOTES) ?></td>
825 <td width="60" class="left top" ><?php echo htmlspecialchars( xl('Takeback'), ENT_QUOTES) ?></td>
826 <td width="40" class="left top" ><?php echo htmlspecialchars( xl('Resn'), ENT_QUOTES) ?></td>
827 <td width="110" class="left top right" ><?php echo htmlspecialchars( xl('Follow Up Reason'), ENT_QUOTES) ?></td>
828 </tr>
829 <?php
831 while ($RowSearch = sqlFetchArray($ResultSearch))
833 $CountIndex++;
834 $CountIndexAbove++;
835 $ServiceDateArray=split(' ',$RowSearch['date']);
836 $ServiceDate=oeFormatShortDate($ServiceDateArray[0]);
837 $Code=$RowSearch['code'];
838 $Modifier =$RowSearch['modifier'];
839 if($Modifier!='')
840 $ModifierString=", $Modifier";
841 else
842 $ModifierString="";
843 $Fee=$RowSearch['fee'];
844 $Encounter=$RowSearch['encounter'];
846 $resPayer = sqlStatement("SELECT payer_type from ar_activity where session_id ='$payment_id' and
847 pid ='$PId' and encounter ='$Encounter' and code='$Code' and modifier='$Modifier' ");
848 $rowPayer = sqlFetchArray($resPayer);
849 $Ins=$rowPayer['payer_type'];
851 //Always associating the copay to a particular charge.
852 $BillingId=$RowSearch['id'];
853 $resId = sqlStatement("SELECT id FROM billing where code_type!='ICD9' and code_type!='COPAY' and
854 pid ='$PId' and encounter ='$Encounter' and billing.activity!=0 order by id");
855 $rowId = sqlFetchArray($resId);
856 $Id=$rowId['id'];
858 if($BillingId!=$Id)//multiple cpt in single encounter
860 $Copay=0.00;
862 else
864 $resCopay = sqlStatement("SELECT sum(fee) as copay FROM billing where
865 code_type='COPAY' and pid ='$PId' and encounter ='$Encounter' and billing.activity!=0");
866 $rowCopay = sqlFetchArray($resCopay);
867 $Copay=$rowCopay['copay']*-1;
869 $resMoneyGot = sqlStatement("SELECT sum(pay_amount) as PatientPay FROM ar_activity where
870 pid ='$PId' and encounter ='$Encounter' and payer_type=0 and
871 (code='CO-PAY' or account_code='PCP')");//new fees screen copay gives account_code='PCP'
872 //openemr payment screen copay gives code='CO-PAY'
873 $rowMoneyGot = sqlFetchArray($resMoneyGot);
874 $PatientPay=$rowMoneyGot['PatientPay'];
876 $Copay=$Copay+$PatientPay;
879 //For calculating Remainder
880 if($Ins==0)
881 {//Fetch all values
882 $resMoneyGot = sqlStatement("SELECT sum(pay_amount) as MoneyGot FROM ar_activity where
883 pid ='$PId' and code='$Code' and modifier='$Modifier' and encounter ='$Encounter' and !(payer_type=0 and
884 (code='CO-PAY' or account_code='PCP'))");
885 //new fees screen copay gives account_code='PCP'
886 //openemr payment screen copay gives code='CO-PAY'
887 $rowMoneyGot = sqlFetchArray($resMoneyGot);
888 $MoneyGot=$rowMoneyGot['MoneyGot'];
890 $resMoneyAdjusted = sqlStatement("SELECT sum(adj_amount) as MoneyAdjusted FROM ar_activity where
891 pid ='$PId' and code='$Code' and modifier='$Modifier' and encounter ='$Encounter'");
892 $rowMoneyAdjusted = sqlFetchArray($resMoneyAdjusted);
893 $MoneyAdjusted=$rowMoneyAdjusted['MoneyAdjusted'];
895 else//Fetch till that much got
897 //Fetch the HIGHEST sequence_no till this session.
898 //Used maily in the case if primary/others pays once more.
899 $resSequence = sqlStatement("SELECT sequence_no from ar_activity where session_id ='$payment_id' and
900 pid ='$PId' and encounter ='$Encounter' order by sequence_no desc ");
901 $rowSequence = sqlFetchArray($resSequence);
902 $Sequence=$rowSequence['sequence_no'];
904 $resMoneyGot = sqlStatement("SELECT sum(pay_amount) as MoneyGot FROM ar_activity where
905 pid ='$PId' and code='$Code' and modifier='$Modifier' and encounter ='$Encounter' and
906 payer_type > 0 and payer_type <='$Ins' and sequence_no<='$Sequence'");
907 $rowMoneyGot = sqlFetchArray($resMoneyGot);
908 $MoneyGot=$rowMoneyGot['MoneyGot'];
910 $resMoneyAdjusted = sqlStatement("SELECT sum(adj_amount) as MoneyAdjusted FROM ar_activity where
911 pid ='$PId' and code='$Code' and modifier='$Modifier' and encounter ='$Encounter' and
912 payer_type > 0 and payer_type <='$Ins' and sequence_no<='$Sequence'");
913 $rowMoneyAdjusted = sqlFetchArray($resMoneyAdjusted);
914 $MoneyAdjusted=$rowMoneyAdjusted['MoneyAdjusted'];
916 $Remainder=$Fee-$Copay-$MoneyGot-$MoneyAdjusted;
918 //For calculating RemainderJS.Used while restoring back the values.
919 if($Ins==0)
920 {//Got just before Patient
921 $resMoneyGot = sqlStatement("SELECT sum(pay_amount) as MoneyGot FROM ar_activity where
922 pid ='$PId' and code='$Code' and modifier='$Modifier' and encounter ='$Encounter' and payer_type !=0");
923 $rowMoneyGot = sqlFetchArray($resMoneyGot);
924 $MoneyGot=$rowMoneyGot['MoneyGot'];
926 $resMoneyAdjusted = sqlStatement("SELECT sum(adj_amount) as MoneyAdjusted FROM ar_activity where
927 pid ='$PId' and code='$Code' and modifier='$Modifier' and encounter ='$Encounter' and payer_type !=0");
928 $rowMoneyAdjusted = sqlFetchArray($resMoneyAdjusted);
929 $MoneyAdjusted=$rowMoneyAdjusted['MoneyAdjusted'];
931 else
932 {//Got just before the previous
933 //Fetch the LOWEST sequence_no till this session.
934 //Used maily in the case if primary/others pays once more.
935 $resSequence = sqlStatement("SELECT sequence_no from ar_activity where session_id ='$payment_id' and
936 pid ='$PId' and encounter ='$Encounter' order by sequence_no ");
937 $rowSequence = sqlFetchArray($resSequence);
938 $Sequence=$rowSequence['sequence_no'];
940 $resMoneyGot = sqlStatement("SELECT sum(pay_amount) as MoneyGot FROM ar_activity where
941 pid ='$PId' and code='$Code' and modifier='$Modifier' and encounter ='$Encounter'
942 and payer_type > 0 and payer_type <='$Ins' and sequence_no<'$Sequence'");
943 $rowMoneyGot = sqlFetchArray($resMoneyGot);
944 $MoneyGot=$rowMoneyGot['MoneyGot'];
946 $resMoneyAdjusted = sqlStatement("SELECT sum(adj_amount) as MoneyAdjusted FROM ar_activity where
947 pid ='$PId' and code='$Code' and modifier='$Modifier' and encounter ='$Encounter'
948 and payer_type <='$Ins' and sequence_no<'$Sequence' ");
949 $rowMoneyAdjusted = sqlFetchArray($resMoneyAdjusted);
950 $MoneyAdjusted=$rowMoneyAdjusted['MoneyAdjusted'];
952 //Stored in hidden so that can be used while restoring back the values.
953 $RemainderJS=$Fee-$Copay-$MoneyGot-$MoneyAdjusted;
955 $resPayment = sqlStatement("SELECT pay_amount from ar_activity where session_id ='$payment_id' and
956 pid ='$PId' and encounter ='$Encounter' and code='$Code' and modifier='$Modifier' and pay_amount>0");
957 $rowPayment = sqlFetchArray($resPayment);
958 $PaymentDB=$rowPayment['pay_amount']*1;
959 $PaymentDB=$PaymentDB == 0 ? '' : $PaymentDB;
961 $resPayment = sqlStatement("SELECT pay_amount from ar_activity where session_id ='$payment_id' and
962 pid ='$PId' and encounter ='$Encounter' and code='$Code' and modifier='$Modifier' and pay_amount<0");
963 $rowPayment = sqlFetchArray($resPayment);
964 $TakebackDB=$rowPayment['pay_amount']*-1;
965 $TakebackDB=$TakebackDB == 0 ? '' : $TakebackDB;
967 $resPayment = sqlStatement("SELECT adj_amount from ar_activity where session_id ='$payment_id' and
968 pid ='$PId' and encounter ='$Encounter' and code='$Code' and modifier='$Modifier' and adj_amount!=0");
969 $rowPayment = sqlFetchArray($resPayment);
970 $AdjAmountDB=$rowPayment['adj_amount']*1;
971 $AdjAmountDB=$AdjAmountDB == 0 ? '' : $AdjAmountDB;
973 $resPayment = sqlStatement("SELECT memo from ar_activity where session_id ='$payment_id' and
974 pid ='$PId' and encounter ='$Encounter' and code='$Code' and modifier='$Modifier' and memo like 'Deductable%'");
975 $rowPayment = sqlFetchArray($resPayment);
976 $DeductibleDB=$rowPayment['memo'];
977 $DeductibleDB=str_replace('Deductable $','',$DeductibleDB);
979 $resPayment = sqlStatement("SELECT follow_up,follow_up_note from ar_activity where session_id ='$payment_id' and
980 pid ='$PId' and encounter ='$Encounter' and code='$Code' and modifier='$Modifier' and follow_up = 'y'");
981 $rowPayment = sqlFetchArray($resPayment);
982 $FollowUpDB=$rowPayment['follow_up'];
983 $FollowUpReasonDB=$rowPayment['follow_up_note'];
985 if($Ins==1)
987 $AllowedDB=number_format($Fee-$AdjAmountDB,2);
989 else
991 $AllowedDB = 0;
993 $AllowedDB=$AllowedDB == 0 ? '' : $AllowedDB;
995 if($CountIndex==$TotalRows)
997 $StringClass=' bottom left top ';
999 else
1001 $StringClass=' left top ';
1004 if($Ins==1)
1006 $bgcolor='#ddddff';
1008 elseif($Ins==2)
1010 $bgcolor='#ffdddd';
1012 elseif($Ins==3)
1014 $bgcolor='#F2F1BC';
1016 elseif($Ins==0)
1018 $bgcolor='#AAFFFF';
1020 $paymenttot=$paymenttot+$PaymentDB;
1021 $adjamttot=$adjamttot+$AdjAmountDB;
1022 $deductibletot=$deductibletot+$DeductibleDB;
1023 $takebacktot=$takebacktot+$TakebackDB;
1024 $allowedtot=$allowedtot+$AllowedDB;
1026 <tr class="text" bgcolor='<?php echo $bgcolor; ?>' id="trCharges<?php echo $CountIndex; ?>">
1027 <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>
1028 <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>
1029 <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>
1030 <td class="<?php echo $StringClass; ?>" ><?php echo htmlspecialchars($ServiceDate); ?></td>
1031 <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>
1032 <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>
1033 <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>
1034 <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>
1035 <td align="right" id="RemainderTd<?php echo $CountIndex; ?>" class="<?php echo $StringClass; ?>" ><?php echo htmlspecialchars(round($Remainder,2)); ?></td>
1036 <input name="HiddenRemainderTd<?php echo $CountIndex; ?>" id="HiddenRemainderTd<?php echo $CountIndex; ?>" value="<?php echo htmlspecialchars(round($RemainderJS,2)); ?>" type="hidden"/>
1037 <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>
1038 <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>
1039 <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>
1040 <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>
1041 <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>
1042 <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>
1043 <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>
1044 </tr>
1045 <?php
1048 }//while ($RowSearch = sqlFetchArray($ResultSearch))
1050 <?php
1051 }//if(sqlNumRows($ResultSearch)>0)
1053 }while ($RowSearchSub = sqlFetchArray($ResultSearchSub));
1054 if($Table=='yes')
1057 <tr class="text">
1058 <td align="left" colspan="9">&nbsp;</td>
1059 <td class="left bottom" bgcolor="#6699FF" id="allowtotal" align="right" ><?php echo htmlspecialchars(number_format($allowedtot,2)); ?></td>
1060 <td class="left bottom" bgcolor="#6699FF" id="paymenttotal" align="right" ><?php echo htmlspecialchars(number_format($paymenttot,2)); ?></td>
1061 <td class="left bottom" bgcolor="#6699FF" id="AdjAmounttotal" align="right" ><?php echo htmlspecialchars(number_format($adjamttot,2)); ?></td>
1062 <td class="left bottom" bgcolor="#6699FF" id="deductibletotal" align="right"><?php echo htmlspecialchars(number_format($deductibletot,2)); ?></td>
1063 <td class="left bottom right" bgcolor="#6699FF" id="takebacktotal" align="right"><?php echo htmlspecialchars(number_format($takebacktot,2)); ?></td>
1064 <td align="center">&nbsp;</td>
1065 <td align="center">&nbsp;</td>
1066 </tr>
1067 </table>
1068 <?php
1072 echo '<br/>';
1074 }//if($RowSearchSub = sqlFetchArray($ResultSearchSub))
1075 ?> </td>
1076 </tr>
1077 <tr>
1078 <td colspan="13" align="left" >
1079 <?php
1080 require_once("payment_pat_sel.inc.php"); //Patient ajax section and listing of charges.
1082 </td>
1083 </tr>
1084 <tr>
1085 <td colspan="13" align="left" >
1086 <table border="0" cellspacing="0" cellpadding="0" width="217" align="center">
1087 <tr height="5">
1088 <td ></td>
1089 <td ></td>
1090 <td></td>
1091 </tr>
1092 <tr>
1093 <td width="110"><a href="#" onClick="javascript:return ModifyPayments();" class="css_button"><span><?php echo htmlspecialchars( xl('Modify Payments'), ENT_QUOTES);?></span></a>
1094 </td>
1095 <td width="107"><a href="#" onClick="javascript:return FinishPayments();" class="css_button"><span><?php echo htmlspecialchars( xl('Finish Payments'), ENT_QUOTES);?></span></a>
1096 </td>
1097 </tr>
1098 </table>
1100 <?php
1101 }//if($payment_id*1>0)
1102 ?> </td>
1103 </tr>
1104 </table>
1105 </td></tr></table>
1107 <input type="hidden" name="hidden_patient_code" id="hidden_patient_code" value="<?php echo htmlspecialchars($hidden_patient_code);?>"/>
1108 <input type='hidden' name='mode' id='mode' value='' />
1109 <input type='hidden' name='ajax_mode' id='ajax_mode' value='' />
1110 <input type="hidden" name="after_value" id="after_value" value="<?php echo htmlspecialchars($_POST["mode"]);?>"/>
1111 <input type="hidden" name="payment_id" id="payment_id" value="<?php echo htmlspecialchars($payment_id);?>"/>
1112 <input type="hidden" name="hidden_type_code" id="hidden_type_code" value="<?php echo htmlspecialchars($TypeCode);?>"/>
1113 <input type='hidden' name='global_amount' id='global_amount' value='' />
1114 <input type='hidden' name='DeletePaymentDistributionId' id='DeletePaymentDistributionId' value='' />
1115 <input type="hidden" name="ActionStatus" id="ActionStatus" value="<?php echo htmlspecialchars($Message);?>"/>
1116 <input type='hidden' name='CountIndexAbove' id='CountIndexAbove' value='<?php echo htmlspecialchars($CountIndexAbove*1);?>' />
1117 <input type='hidden' name='CountIndexBelow' id='CountIndexBelow' value='<?php echo htmlspecialchars($CountIndexBelow*1);?>' />
1118 <input type="hidden" name="ParentPage" id="ParentPage" value="<?php echo htmlspecialchars($_REQUEST['ParentPage']);?>"/>
1119 </form>
1121 </body>
1122 </html>