2 // +-----------------------------------------------------------------------------+
3 // Copyright (C) 2010 Z&H Consultancy Services Private Limited <sam@zhservices.com>
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
18 // A copy of the GNU General Public License is included along with this program:
19 // openemr/interface/login/GnuGPL.html
20 // For more information write to the Free Software
21 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 // Author: Eldho Chacko <eldho@zhservices.com>
24 // Paul Simon K <paul@zhservices.com>
26 // +------------------------------------------------------------------------------+
27 //===============================================================================
28 //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/auth.inc");
38 require_once("../../custom/code_types.inc.php");
39 require_once("$srcdir/patient.inc");
40 require_once("$srcdir/billrep.inc");
41 require_once("$srcdir/options.inc.php");
42 require_once("$srcdir/payment.inc.php");
43 //===============================================================================
44 $screen='edit_payment';
45 //===============================================================================
46 // deletion of payment distribution code
47 //===============================================================================
48 if (isset($_POST["mode"]))
50 if ($_POST["mode"] == "DeletePaymentDistribution")
52 $DeletePaymentDistributionId=trim(formData('DeletePaymentDistributionId' ));
53 $DeletePaymentDistributionIdArray=explode('_',$DeletePaymentDistributionId);
54 $payment_id=$DeletePaymentDistributionIdArray[0];
55 $PId=$DeletePaymentDistributionIdArray[1];
56 $Encounter=$DeletePaymentDistributionIdArray[2];
57 $Code=$DeletePaymentDistributionIdArray[3];
58 $Modifier=$DeletePaymentDistributionIdArray[4];
59 $Codetype=$DeletePaymentDistributionIdArray[5];
60 //delete and log that action
61 row_delete("ar_activity", "session_id ='$payment_id' and pid ='$PId' AND " .
62 "encounter='$Encounter' and code_type='$Codetype' and code='$Code' and modifier='$Modifier'");
65 $_POST["mode"] = "searchdatabase";
68 //===============================================================================
69 //Modify Payment Code.
70 //===============================================================================
71 if (isset($_POST["mode"]))
73 if ($_POST["mode"] == "ModifyPayments" ||
$_POST["mode"] == "FinishPayments")
75 $payment_id=$_REQUEST['payment_id'];
77 //===============================================================================
78 if(trim(formData('type_name' ))=='insurance')
80 $QueryPart="payer_id = '" . trim(formData('hidden_type_code' )) .
81 "', patient_id = '" . 0 ;
83 elseif(trim(formData('type_name' ))=='patient')
85 $QueryPart="payer_id = '" . 0 .
86 "', patient_id = '" . trim(formData('hidden_type_code' )) ;
88 $user_id=$_SESSION['authUserID'];
90 $modified_time = date('Y-m-d H:i:s');
91 $check_date=DateToYYYYMMDD(formData('check_date'));
92 $deposit_date=DateToYYYYMMDD(formData('deposit_date'));
93 $post_to_date=DateToYYYYMMDD(formData('post_to_date'));
95 $post_to_date=date('Y-m-d');
96 if(formData('deposit_date')=='')
97 $deposit_date=$post_to_date;
99 sqlStatement("update ar_session set " .
101 "', user_id = '" . trim($user_id ) .
102 "', closed = '" . trim($closed ) .
103 "', reference = '" . trim(formData('check_number' )) .
104 "', check_date = '" . trim($check_date ) .
105 "', deposit_date = '" . trim($deposit_date ) .
106 "', pay_total = '" . trim(formData('payment_amount')) .
107 "', modified_time = '" . trim($modified_time ) .
108 "', payment_type = '" . trim(formData('type_name' )) .
109 "', description = '" . trim(formData('description' )) .
110 "', adjustment_code = '" . trim(formData('adjustment_code' )) .
111 "', post_to_date = '" . trim($post_to_date ) .
112 "', payment_method = '" . trim(formData('payment_method' )) .
113 "' where session_id='$payment_id'");
114 //===============================================================================
115 $CountIndexAbove=$_REQUEST['CountIndexAbove'];
116 $CountIndexBelow=$_REQUEST['CountIndexBelow'];
117 $hidden_patient_code=$_REQUEST['hidden_patient_code'];
118 $user_id=$_SESSION['authUserID'];
119 $created_time = date('Y-m-d H:i:s');
120 //==================================================================
122 //It is done with out deleting any old entries.
123 //==================================================================
124 for($CountRow=1;$CountRow<=$CountIndexAbove;$CountRow++
)
126 if (isset($_POST["HiddenEncounter$CountRow"]))
128 if (isset($_POST["Payment$CountRow"]) && $_POST["Payment$CountRow"]*1>0)
130 if(trim(formData('type_name' ))=='insurance')
132 if(trim(formData("HiddenIns$CountRow" ))==1)
136 if(trim(formData("HiddenIns$CountRow" ))==2)
140 if(trim(formData("HiddenIns$CountRow" ))==3)
145 elseif(trim(formData('type_name' ))=='patient')
149 $resPayment = sqlStatement("SELECT * from ar_activity " .
150 " where session_id ='$payment_id' and pid ='" . trim(formData("HiddenPId$CountRow" )) .
151 "' and encounter ='" . trim(formData("HiddenEncounter$CountRow" )) .
152 "' and code_type ='" . trim(formData("HiddenCodetype$CountRow" )) .
153 "' and code ='" . trim(formData("HiddenCode$CountRow" )) .
154 "' and modifier ='" . trim(formData("HiddenModifier$CountRow" )) .
155 "' and pay_amount>0");
156 if(sqlNumRows($resPayment)>0)
158 sqlStatement("update ar_activity set " .
159 " post_user = '" . trim($user_id ) .
160 "', modified_time = '" . trim($created_time ) .
161 "', pay_amount = '" . trim(formData("Payment$CountRow" )) .
162 "', account_code = '" . "$AccountCode" .
163 "', payer_type = '" . trim(formData("HiddenIns$CountRow" )) .
164 "', reason_code = '" . trim(formData("ReasonCode$CountRow" )) .
165 "' where session_id ='$payment_id' and pid ='" . trim(formData("HiddenPId$CountRow" )) .
166 "' and encounter ='" . trim(formData("HiddenEncounter$CountRow" )) .
167 "' and code_type ='" . trim(formData("HiddenCodetype$CountRow" )) .
168 "' and code ='" . trim(formData("HiddenCode$CountRow" )) .
169 "' and modifier ='" . trim(formData("HiddenModifier$CountRow" )) .
170 "' and pay_amount>0");
175 $sequence_no = sqlQuery( "SELECT IFNULL(MAX(sequence_no),0) + 1 AS increment FROM ar_activity WHERE pid = ? AND encounter = ?", array(trim(formData("HiddenPId$CountRow" )), trim(formData("HiddenEncounter$CountRow" ))));
176 sqlStatement("insert into ar_activity set " .
177 "pid = '" . trim(formData("HiddenPId$CountRow" )) .
178 "', encounter = '" . trim(formData("HiddenEncounter$CountRow" )) .
179 "', sequence_no = '" . $sequence_no['increment'] .
180 "', code_type = '" . trim(formData("HiddenCodetype$CountRow" )) .
181 "', code = '" . trim(formData("HiddenCode$CountRow" )) .
182 "', modifier = '" . trim(formData("HiddenModifier$CountRow" )) .
183 "', payer_type = '" . trim(formData("HiddenIns$CountRow" )) .
184 "', reason_code = '" . trim(formData("ReasonCode$CountRow" )) .
185 "', post_time = '" . trim($created_time ) .
186 "', post_user = '" . trim($user_id ) .
187 "', session_id = '" . trim(formData('payment_id')) .
188 "', modified_time = '" . trim($created_time ) .
189 "', pay_amount = '" . trim(formData("Payment$CountRow" )) .
190 "', adj_amount = '" . 0 .
191 "', account_code = '" . "$AccountCode" .
198 sqlStatement("delete from ar_activity " .
199 " where session_id ='$payment_id' and pid ='" . trim(formData("HiddenPId$CountRow" )) .
200 "' and encounter ='" . trim(formData("HiddenEncounter$CountRow" )) .
201 "' and code_type ='" . trim(formData("HiddenCodetype$CountRow" )) .
202 "' and code ='" . trim(formData("HiddenCode$CountRow" )) .
203 "' and modifier ='" . trim(formData("HiddenModifier$CountRow" )) .
204 "' and pay_amount>0");
206 //==============================================================================================================================
207 if (isset($_POST["AdjAmount$CountRow"]) && $_POST["AdjAmount$CountRow"]*1!=0)
209 if(trim(formData('type_name' ))=='insurance')
211 $AdjustString="Ins adjust Ins".trim(formData("HiddenIns$CountRow" ));
214 elseif(trim(formData('type_name' ))=='patient')
216 $AdjustString="Pt adjust";
219 $resPayment = sqlStatement("SELECT * from ar_activity " .
220 " where session_id ='$payment_id' and pid ='" . trim(formData("HiddenPId$CountRow" )) .
221 "' and encounter ='" . trim(formData("HiddenEncounter$CountRow" )) .
222 "' and code_type ='" . trim(formData("HiddenCodetype$CountRow" )) .
223 "' and code ='" . trim(formData("HiddenCode$CountRow" )) .
224 "' and modifier ='" . trim(formData("HiddenModifier$CountRow" )) .
225 "' and adj_amount!=0");
226 if(sqlNumRows($resPayment)>0)
228 sqlStatement("update ar_activity set " .
229 " post_user = '" . trim($user_id ) .
230 "', modified_time = '" . trim($created_time ) .
231 "', adj_amount = '" . trim(formData("AdjAmount$CountRow" )) .
232 "', memo = '" . "$AdjustString" .
233 "', account_code = '" . "$AccountCode" .
234 "', payer_type = '" . trim(formData("HiddenIns$CountRow" )) .
235 "' where session_id ='$payment_id' and pid ='" . trim(formData("HiddenPId$CountRow" )) .
236 "' and encounter ='" . trim(formData("HiddenEncounter$CountRow" )) .
237 "' and code_type ='" . trim(formData("HiddenCodetype$CountRow" )) .
238 "' and code ='" . trim(formData("HiddenCode$CountRow" )) .
239 "' and modifier ='" . trim(formData("HiddenModifier$CountRow" )) .
240 "' and adj_amount!=0");
245 $sequence_no = sqlQuery( "SELECT IFNULL(MAX(sequence_no),0) + 1 AS increment FROM ar_activity WHERE pid = ? AND encounter = ?", array(trim(formData("HiddenPId$CountRow" )), trim(formData("HiddenEncounter$CountRow" ))));
246 sqlStatement("insert into ar_activity set " .
247 "pid = '" . trim(formData("HiddenPId$CountRow" )) .
248 "', encounter = '" . trim(formData("HiddenEncounter$CountRow" )) .
249 "', sequence_no = '" . $sequence_no['increment'] .
250 "', code_type = '" . trim(formData("HiddenCodetype$CountRow" )) .
251 "', code = '" . trim(formData("HiddenCode$CountRow" )) .
252 "', modifier = '" . trim(formData("HiddenModifier$CountRow" )) .
253 "', payer_type = '" . trim(formData("HiddenIns$CountRow" )) .
254 "', post_time = '" . trim($created_time ) .
255 "', post_user = '" . trim($user_id ) .
256 "', session_id = '" . trim(formData('payment_id')) .
257 "', modified_time = '" . trim($created_time ) .
258 "', pay_amount = '" . 0 .
259 "', adj_amount = '" . trim(formData("AdjAmount$CountRow" )) .
260 "', memo = '" . "$AdjustString" .
261 "', account_code = '" . "$AccountCode" .
269 sqlStatement("delete from ar_activity " .
270 " where session_id ='$payment_id' and pid ='" . trim(formData("HiddenPId$CountRow" )) .
271 "' and encounter ='" . trim(formData("HiddenEncounter$CountRow" )) .
272 "' and code_type ='" . trim(formData("HiddenCodetype$CountRow" )) .
273 "' and code ='" . trim(formData("HiddenCode$CountRow" )) .
274 "' and modifier ='" . trim(formData("HiddenModifier$CountRow" )) .
275 "' and adj_amount!=0");
277 //==============================================================================================================================
278 if (isset($_POST["Deductible$CountRow"]) && $_POST["Deductible$CountRow"]*1>0)
280 $resPayment = sqlStatement("SELECT * from ar_activity " .
281 " where session_id ='$payment_id' and pid ='" . trim(formData("HiddenPId$CountRow" )) .
282 "' and encounter ='" . trim(formData("HiddenEncounter$CountRow" )) .
283 "' and code_type ='" . trim(formData("HiddenCodetype$CountRow" )) .
284 "' and code ='" . trim(formData("HiddenCode$CountRow" )) .
285 "' and modifier ='" . trim(formData("HiddenModifier$CountRow" )) .
286 "' and (memo like 'Deductable%' OR memo like 'Deductible%')");
287 if(sqlNumRows($resPayment)>0)
289 sqlStatement("update ar_activity set " .
290 " post_user = '" . trim($user_id ) .
291 "', modified_time = '" . trim($created_time ) .
292 "', memo = '" . "Deductible $".trim(formData("Deductible$CountRow" )) .
293 "', account_code = '" . "Deduct" .
294 "', payer_type = '" . trim(formData("HiddenIns$CountRow" )) .
295 "' where session_id ='$payment_id' and pid ='" . trim(formData("HiddenPId$CountRow" )) .
296 "' and encounter ='" . trim(formData("HiddenEncounter$CountRow" )) .
297 "' and code_type ='" . trim(formData("HiddenCodetype$CountRow" )) .
298 "' and code ='" . trim(formData("HiddenCode$CountRow" )) .
299 "' and modifier ='" . trim(formData("HiddenModifier$CountRow" )) .
300 "' and (memo like 'Deductable%' OR memo like 'Deductible%')");
305 $sequence_no = sqlQuery( "SELECT IFNULL(MAX(sequence_no),0) + 1 AS increment FROM ar_activity WHERE pid = ? AND encounter = ?", array(trim(formData("HiddenPId$CountRow")), trim(formData("HiddenEncounter$CountRow"))));
306 sqlStatement("insert into ar_activity set " .
307 "pid = '" . trim(formData("HiddenPId$CountRow" )) .
308 "', encounter = '" . trim(formData("HiddenEncounter$CountRow" )) .
309 "', sequence_no = '" . $sequence_no['increment'] .
310 "', code_type = '" . trim(formData("HiddenCodetype$CountRow" )) .
311 "', code = '" . trim(formData("HiddenCode$CountRow" )) .
312 "', modifier = '" . trim(formData("HiddenModifier$CountRow" )) .
313 "', payer_type = '" . trim(formData("HiddenIns$CountRow" )) .
314 "', post_time = '" . trim($created_time ) .
315 "', post_user = '" . trim($user_id ) .
316 "', session_id = '" . trim(formData('payment_id')) .
317 "', modified_time = '" . trim($created_time ) .
318 "', pay_amount = '" . 0 .
319 "', adj_amount = '" . 0 .
320 "', memo = '" . "Deductible $".trim(formData("Deductible$CountRow" )) .
321 "', account_code = '" . "Deduct" .
328 sqlStatement("delete from ar_activity " .
329 " where session_id ='$payment_id' and pid ='" . trim(formData("HiddenPId$CountRow" )) .
330 "' and encounter ='" . trim(formData("HiddenEncounter$CountRow" )) .
331 "' and code_type ='" . trim(formData("HiddenCodetype$CountRow" )) .
332 "' and code ='" . trim(formData("HiddenCode$CountRow" )) .
333 "' and modifier ='" . trim(formData("HiddenModifier$CountRow" )) .
334 "' and (memo like 'Deductable%' OR memo like 'Deductible%')");
336 //==============================================================================================================================
337 if (isset($_POST["Takeback$CountRow"]) && $_POST["Takeback$CountRow"]*1>0)
339 $resPayment = sqlStatement("SELECT * from ar_activity " .
340 " where session_id ='$payment_id' and pid ='" . trim(formData("HiddenPId$CountRow" )) .
341 "' and encounter ='" . trim(formData("HiddenEncounter$CountRow" )) .
342 "' and code_type ='" . trim(formData("HiddenCodetype$CountRow" )) .
343 "' and code ='" . trim(formData("HiddenCode$CountRow" )) .
344 "' and modifier ='" . trim(formData("HiddenModifier$CountRow" )) .
345 "' and pay_amount < 0");
346 if(sqlNumRows($resPayment)>0)
348 sqlStatement("update ar_activity set " .
349 " post_user = '" . trim($user_id ) .
350 "', modified_time = '" . trim($created_time ) .
351 "', pay_amount = '" . trim(formData("Takeback$CountRow" ))*-1 .
352 "', account_code = '" . "Takeback" .
353 "', payer_type = '" . trim(formData("HiddenIns$CountRow" )) .
354 "' where session_id ='$payment_id' and pid ='" . trim(formData("HiddenPId$CountRow" )) .
355 "' and encounter ='" . trim(formData("HiddenEncounter$CountRow" )) .
356 "' and code_type ='" . trim(formData("HiddenCodetype$CountRow" )) .
357 "' and code ='" . trim(formData("HiddenCode$CountRow" )) .
358 "' and modifier ='" . trim(formData("HiddenModifier$CountRow" )) .
359 "' and pay_amount < 0");
364 $sequence_no = sqlQuery( "SELECT IFNULL(MAX(sequence_no),0) + 1 AS increment FROM ar_activity WHERE pid = ? AND encounter = ?", array(trim(formData("HiddenPId$CountRow" )), trim(formData("HiddenEncounter$CountRow" ))));
365 sqlStatement("insert into ar_activity set " .
366 "pid = '" . trim(formData("HiddenPId$CountRow" )) .
367 "', encounter = '" . trim(formData("HiddenEncounter$CountRow" )) .
368 "', sequence_no = '" . $sequence_no['increment'] .
369 "', code_type = '" . trim(formData("HiddenCodetype$CountRow" )) .
370 "', code = '" . trim(formData("HiddenCode$CountRow" )) .
371 "', modifier = '" . trim(formData("HiddenModifier$CountRow" )) .
372 "', payer_type = '" . trim(formData("HiddenIns$CountRow" )) .
373 "', post_time = '" . trim($created_time ) .
374 "', post_user = '" . trim($user_id ) .
375 "', session_id = '" . trim(formData('payment_id')) .
376 "', modified_time = '" . trim($created_time ) .
377 "', pay_amount = '" . trim(formData("Takeback$CountRow" ))*-1 .
378 "', adj_amount = '" . 0 .
379 "', account_code = '" . "Takeback" .
386 sqlStatement("delete from ar_activity " .
387 " where session_id ='$payment_id' and pid ='" . trim(formData("HiddenPId$CountRow" )) .
388 "' and encounter ='" . trim(formData("HiddenEncounter$CountRow" )) .
389 "' and code_type ='" . trim(formData("HiddenCodetype$CountRow" )) .
390 "' and code ='" . trim(formData("HiddenCode$CountRow" )) .
391 "' and modifier ='" . trim(formData("HiddenModifier$CountRow" )) .
392 "' and pay_amount < 0");
394 //==============================================================================================================================
395 if (isset($_POST["FollowUp$CountRow"]) && $_POST["FollowUp$CountRow"]=='y')
397 $resPayment = sqlStatement("SELECT * from ar_activity " .
398 " where session_id ='$payment_id' and pid ='" . trim(formData("HiddenPId$CountRow" )) .
399 "' and encounter ='" . trim(formData("HiddenEncounter$CountRow" )) .
400 "' and code_type ='" . trim(formData("HiddenCodetype$CountRow" )) .
401 "' and code ='" . trim(formData("HiddenCode$CountRow" )) .
402 "' and modifier ='" . trim(formData("HiddenModifier$CountRow" )) .
403 "' and follow_up ='y'");
404 if(sqlNumRows($resPayment)>0)
406 sqlStatement("update ar_activity set " .
407 " post_user = '" . trim($user_id ) .
408 "', modified_time = '" . trim($created_time ) .
409 "', follow_up = '" . "y" .
410 "', follow_up_note = '" . trim(formData("FollowUpReason$CountRow" )) .
411 "', payer_type = '" . trim(formData("HiddenIns$CountRow" )) .
412 "' where session_id ='$payment_id' and pid ='" . trim(formData("HiddenPId$CountRow" )) .
413 "' and encounter ='" . trim(formData("HiddenEncounter$CountRow" )) .
414 "' and code_type ='" . trim(formData("HiddenCodetype$CountRow" )) .
415 "' and code ='" . trim(formData("HiddenCode$CountRow" )) .
416 "' and modifier ='" . trim(formData("HiddenModifier$CountRow" )) .
417 "' and follow_up ='y'");
422 $sequence_no = sqlQuery( "SELECT IFNULL(MAX(sequence_no),0) + 1 AS increment FROM ar_activity WHERE pid = ? AND encounter = ?", array(trim(formData("HiddenPId$CountRow" )), trim(formData("HiddenEncounter$CountRow" ))));
423 sqlStatement("insert into ar_activity set " .
424 "pid = '" . trim(formData("HiddenPId$CountRow" )) .
425 "', encounter = '" . trim(formData("HiddenEncounter$CountRow" )) .
426 "', sequence_no = '" . $sequence_no['increment'] .
427 "', code_type = '" . trim(formData("HiddenCodetype$CountRow" )) .
428 "', code = '" . trim(formData("HiddenCode$CountRow" )) .
429 "', modifier = '" . trim(formData("HiddenModifier$CountRow" )) .
430 "', payer_type = '" . trim(formData("HiddenIns$CountRow" )) .
431 "', post_time = '" . trim($created_time ) .
432 "', post_user = '" . trim($user_id ) .
433 "', session_id = '" . trim(formData('payment_id')) .
434 "', modified_time = '" . trim($created_time ) .
435 "', pay_amount = '" . 0 .
436 "', adj_amount = '" . 0 .
437 "', follow_up = '" . "y" .
438 "', follow_up_note = '" . trim(formData("FollowUpReason$CountRow" )) .
445 sqlStatement("delete from ar_activity " .
446 " where session_id ='$payment_id' and pid ='" . trim(formData("HiddenPId$CountRow" )) .
447 "' and encounter ='" . trim(formData("HiddenEncounter$CountRow" )) .
448 "' and code_type ='" . trim(formData("HiddenCodetype$CountRow" )) .
449 "' and code ='" . trim(formData("HiddenCode$CountRow" )) .
450 "' and modifier ='" . trim(formData("HiddenModifier$CountRow" )) .
451 "' and follow_up ='y'");
453 //==============================================================================================================================
459 //INSERTION of new entries,continuation of modification.
461 for($CountRow=$CountIndexAbove+
1;$CountRow<=$CountIndexAbove+
$CountIndexBelow;$CountRow++
)
463 if (isset($_POST["HiddenEncounter$CountRow"]))
465 DistributionInsert($CountRow,$created_time,$user_id);
470 if($_REQUEST['global_amount']=='yes')
471 sqlStatement("update ar_session set global_amount=".trim(formData("HidUnappliedAmount" ))*1 ." where session_id ='$payment_id'");
472 if($_POST["mode"]=="FinishPayments")
476 $_POST["mode"] = "searchdatabase";
480 //==============================================================================
482 //===============================================================================
483 $payment_id=$payment_id*1 > 0 ?
$payment_id : $_REQUEST['payment_id'];
484 $ResultSearchSub = sqlStatement("SELECT distinct encounter,code_type,code,modifier, pid from ar_activity where session_id ='$payment_id' order by pid,encounter,code,modifier");
485 //==============================================================================
487 //==============================================================================
488 //===============================================================================
493 <?php
if (function_exists('html_header_show')) html_header_show(); ?
>
495 <link rel
="stylesheet" href
="<?php echo $css_header;?>" type
="text/css">
496 <link rel
="stylesheet" type
="text/css" href
="../../library/js/fancybox/jquery.fancybox-1.2.6.css" media
="screen" />
497 <link rel
="stylesheet" href
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.min.css">
499 <!-- supporting javascript code
-->
500 <script type
="text/javascript" src
="../../library/textformat.js?v=<?php echo $v_js_includes; ?>"></script
>
501 <script type
="text/javascript" src
="../../library/dialog.js?v=<?php echo $v_js_includes; ?>"></script
>
502 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-7-2/index.js"></script
>
503 <script type
="text/javascript" src
="../../library/js/fancybox/jquery.fancybox-1.2.6.js"></script
>
504 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.full.min.js"></script
>
506 <script language
='JavaScript'>
509 <?php
include_once("{$GLOBALS['srcdir']}/payment_jav.inc.php"); ?
>
510 <?php
include_once("{$GLOBALS['srcdir']}/ajax/payment_ajax_jav.inc.php"); ?
>
511 <script type
="text/javascript" src
="../../library/js/common.js?v=<?php echo $v_js_includes; ?>"></script
>
512 <script LANGUAGE
="javascript" TYPE
="text/javascript">
513 function ModifyPayments()
514 {//Used while modifying the allocation
515 if(!FormValidations())//FormValidations contains the form checks
519 if(CompletlyBlankAbove())//The distribution rows already in the database are checked.
521 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) ?>")
524 if(!CheckPayingEntityAndDistributionPostFor())//Ensures that Insurance payment is distributed under Ins1,Ins2,Ins3 and Patient paymentat under Pat.
528 if(CompletlyBlankBelow())//The newly added distribution rows are checked.
530 alert("<?php echo htmlspecialchars( xl('Fill any of the Below Row.'), ENT_QUOTES) ?>")
533 PostValue
=CheckUnappliedAmount();//Decides TdUnappliedAmount >0, or <0 or =0
536 alert("<?php echo htmlspecialchars( xl('Cannot Modify Payments.Undistributed is Negative.'), ENT_QUOTES) ?>")
539 if(confirm("<?php echo htmlspecialchars( xl('Would you like to Modify Payments?'), ENT_QUOTES) ?>"))
541 document
.getElementById('mode').value
='ModifyPayments';
542 top
.restoreSession();
543 document
.forms
[0].submit();
548 function FinishPayments()
550 if(!FormValidations())//FormValidations contains the form checks
554 if(CompletlyBlankAbove())//The distribution rows already in the database are checked.
556 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) ?>")
559 if(!CheckPayingEntityAndDistributionPostFor())//Ensures that Insurance payment is distributed under Ins1,Ins2,Ins3 and Patient paymentat under Pat.
563 if(CompletlyBlankBelow())//The newly added distribution rows are checked.
565 alert("<?php echo htmlspecialchars( xl('Fill any of the Below Row.'), ENT_QUOTES) ?>")
568 PostValue
=CheckUnappliedAmount();//Decides TdUnappliedAmount >0, or <0 or =0
571 alert("<?php echo htmlspecialchars( xl('Cannot Modify Payments.Undistributed is Negative.'), ENT_QUOTES) ?>")
576 if(confirm("<?php echo htmlspecialchars( xl('Would you like to Modify and Finish Payments?'), ENT_QUOTES) ?>"))
578 UnappliedAmount
=document
.getElementById('TdUnappliedAmount').innerHTML
*1;
579 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) ?>"))
581 document
.getElementById('mode').value
='FinishPayments';
582 document
.getElementById('global_amount').value
='yes';
583 top
.restoreSession();
584 document
.forms
[0].submit();
588 document
.getElementById('mode').value
='FinishPayments';
589 top
.restoreSession();
590 document
.forms
[0].submit();
598 if(confirm("<?php echo htmlspecialchars( xl('Would you like to Modify and Finish Payments?'), ENT_QUOTES) ?>"))
600 document
.getElementById('mode').value
='FinishPayments';
601 top
.restoreSession();
602 document
.forms
[0].submit();
609 function CompletlyBlankAbove()
610 {//The distribution rows already in the database are checked.
611 //It is not allowed to be made completly empty.If needed delete option need to be used.
612 CountIndexAbove
=document
.getElementById('CountIndexAbove').value
*1;
613 for(RowCount
=1;RowCount
<=CountIndexAbove
;RowCount++
)
615 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)
622 function CompletlyBlankBelow()
623 {//The newly added distribution rows are checked.
624 //It is not allowed to be made completly empty.
625 CountIndexAbove
=document
.getElementById('CountIndexAbove').value
*1;
626 CountIndexBelow
=document
.getElementById('CountIndexBelow').value
*1;
627 if(CountIndexBelow
==0)
629 for(RowCount
=CountIndexAbove+
1;RowCount
<=CountIndexAbove+CountIndexBelow
;RowCount++
)
631 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)
640 function OnloadAction()
641 {//Displays message while loading after some action.
642 after_value
=document
.getElementById('ActionStatus').value
;
643 if(after_value
=='Delete')
645 alert("<?php echo htmlspecialchars( xl('Successfully Deleted'), ENT_QUOTES) ?>")
648 if(after_value
=='Modify' || after_value
=='Finish')
650 alert("<?php echo htmlspecialchars( xl('Successfully Modified'), ENT_QUOTES) ?>")
653 after_value
=document
.getElementById('after_value').value
;
654 payment_id
=document
.getElementById('payment_id').value
;
655 if(after_value
=='distribute')
658 else if(after_value
=='new_payment')
660 if(document
.getElementById('TablePatientPortion'))
662 document
.getElementById('TablePatientPortion').style
.display
='none';
664 if(confirm("<?php echo htmlspecialchars( xl('Successfully Saved.Would you like to Distribute?'), ENT_QUOTES) ?>"))
666 if(document
.getElementById('TablePatientPortion'))
668 document
.getElementById('TablePatientPortion').style
.display
='';
674 function DeletePaymentDistribution(DeleteId
)
675 {//Confirms deletion of payment distribution.
676 if(confirm("<?php echo htmlspecialchars( xl('Would you like to Delete Payment Distribution?'), ENT_QUOTES) ?>"))
678 document
.getElementById('mode').value
='DeletePaymentDistribution';
679 document
.getElementById('DeletePaymentDistributionId').value
=DeleteId
;
680 top
.restoreSession();
681 document
.forms
[0].submit();
686 //========================================================================================
688 $
(document
).ready(function() {
689 $
('.datepicker').datetimepicker({
690 <?php
$datetimepicker_timepicker = false; ?
>
691 <?php
$datetimepicker_showseconds = false; ?
>
692 <?php
$datetimepicker_formatInput = true; ?
>
693 <?php
require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?
>
694 <?php
// can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
699 <script language
="javascript" type
="text/javascript">
700 document
.onclick
=HideTheAjaxDivs
;
703 .class1
{width
:125px
;}
704 .class2
{width
:250px
;}
705 .class3
{width
:100px
;}
706 .bottom
{border
-bottom
:1px solid black
;}
707 .top
{border
-top
:1px solid black
;}
708 .left
{border
-left
:1px solid black
;}
709 .right
{border
-right
:1px solid black
;}
710 #ajax_div_insurance {
717 background
-color
: #FBFDD0;
718 border
: 1px solid
#ccc;
728 background
-color
: #FBFDD0;
729 border
: 1px solid
#ccc;
733 <link rel
="stylesheet" href
="<?php echo $css_header; ?>" type
="text/css">
735 <body
class="body_top" onLoad
="OnloadAction()" >
736 <form name
='new_payment' method
='post' action
="edit_payment.php" onsubmit
='
741 top.restoreSession();return SavePayment();
751 ' style
="display:inline" >
752 <table width
="1024" border
="0" cellspacing
="0" cellpadding
="0">
754 if($_REQUEST['ParentPage']=='new_payment')
758 <td colspan
="3" align
="left"><b
><?php
echo htmlspecialchars( xl('Payments'), ENT_QUOTES
) ?
></b
></td
>
761 <td colspan
="3" align
="left" ></td
>
764 <td colspan
="3" align
="left">
766 <li
class='current'><a href
='new_payment.php'><?php
echo htmlspecialchars( xl('New Payment'), ENT_QUOTES
) ?
></a
></li
>
767 <li
><a href
='search_payments.php'><?php
echo htmlspecialchars( xl('Search Payment'), ENT_QUOTES
) ?
></a
></li
>
768 <li
><a href
='era_payments.php'><?php
echo htmlspecialchars( xl('ERA Posting'), ENT_QUOTES
) ?
></a
></li
>
777 <td colspan
="3" align
="left" ></td
>
783 <td colspan
="3" align
="left" >
790 require_once("payment_master.inc.php"); //Check/cash details are entered here.
803 {//Distribution rows already in the database are displayed.
806 <table width
="1024" border
="0" cellspacing
="0" cellpadding
="10" bgcolor
="#DEDEDE"><tr
><td
>
807 <table width
="1004" border
="0" cellspacing
="0" cellpadding
="0">
810 <td colspan
="13" align
="left" >
813 $resCount = sqlStatement("SELECT distinct encounter,code_type,code,modifier from ar_activity where session_id ='$payment_id' ");
814 $TotalRows=sqlNumRows($resCount);
823 if($RowSearchSub = sqlFetchArray($ResultSearchSub))
828 $PId=$RowSearchSub['pid'];
829 $EncounterMaster=$RowSearchSub['encounter'];
830 // Only use the code_type in the queries below if it is specified in the ar_activity table.
831 // If it is not specified in the ar_activity table, also note it is not requested from the
832 // billing table in below query, thus making it blank in all queries below in this script.
833 $CodetypeMaster=$RowSearchSub['code_type'];
834 $sql_select_part_codetype = "";
835 $sql_where_part_codetype = "";
836 if (!empty($CodetypeMaster)) {
837 $sql_select_part_codetype = "billing.code_type,";
838 $sql_where_part_codetype = "and billing.code_type ='$CodetypeMaster'";
840 $CodeMaster=$RowSearchSub['code'];
841 $ModifierMaster=$RowSearchSub['modifier'];
842 $res = sqlStatement("SELECT fname,lname,mname FROM patient_data where pid ='$PId'");
843 $row = sqlFetchArray($res);
844 $fname=$row['fname'];
845 $lname=$row['lname'];
846 $mname=$row['mname'];
847 $NameDB=$lname.' '.$fname.' '.$mname;
848 $ResultSearch = sqlStatement("SELECT billing.id,last_level_closed,billing.encounter,form_encounter.`date`,$sql_select_part_codetype billing.code,billing.modifier,fee
849 FROM billing ,form_encounter
850 where billing.encounter=form_encounter.encounter and billing.pid=form_encounter.pid and
851 code_type!='ICD9' and code_type!='COPAY' and billing.activity!=0 and
852 form_encounter.pid ='$PId' and billing.pid ='$PId' and billing.encounter ='$EncounterMaster'
853 $sql_where_part_codetype
854 and billing.code ='$CodeMaster'
855 and billing.modifier ='$ModifierMaster'
856 ORDER BY form_encounter.`date`,form_encounter.encounter,billing.code,billing.modifier");
857 if(sqlNumRows($ResultSearch)>0)
863 <table width
="1004" border
="0" cellpadding
="0" cellspacing
="0" align
="center" id
="TableDistributePortion">
864 <tr
class="text" bgcolor
="#dddddd">
865 <td width
="25" class="left top" > 
;</td
>
866 <td width
="144" class="left top" ><?php
echo htmlspecialchars( xl('Patient Name'), ENT_QUOTES
) ?
></td
>
867 <td width
="55" class="left top" ><?php
echo htmlspecialchars( xl('Post For'), ENT_QUOTES
) ?
></td
>
868 <td width
="70" class="left top" ><?php
echo htmlspecialchars( xl('Service Date'), ENT_QUOTES
) ?
></td
>
869 <td width
="50" class="left top" ><?php
echo htmlspecialchars( xl('Encounter'), ENT_QUOTES
) ?
></td
>
870 <td width
="65" class="left top" ><?php
echo htmlspecialchars( xl('Service Code'), ENT_QUOTES
) ?
></td
>
871 <td width
="50" class="left top" ><?php
echo htmlspecialchars( xl('Charge'), ENT_QUOTES
) ?
></td
>
872 <td width
="40" class="left top" ><?php
echo htmlspecialchars( xl('Copay'), ENT_QUOTES
) ?
></td
>
873 <td width
="40" class="left top" ><?php
echo htmlspecialchars( xl('Remdr'), ENT_QUOTES
) ?
></td
>
874 <td width
="60" class="left top" ><?php
echo htmlspecialchars( xl('Allowed(c)'), ENT_QUOTES
) ?
></td
><!-- (c
) means it is calculated
.Not stored one
. -->
875 <td width
="60" class="left top" ><?php
echo htmlspecialchars( xl('Payment'), ENT_QUOTES
) ?
></td
>
876 <td width
="70" class="left top" ><?php
echo htmlspecialchars( xl('Adj Amount'), ENT_QUOTES
) ?
></td
>
877 <td width
="60" class="left top" ><?php
echo htmlspecialchars( xl('Deductible'), ENT_QUOTES
) ?
></td
>
878 <td width
="60" class="left top" ><?php
echo htmlspecialchars( xl('Takeback'), ENT_QUOTES
) ?
></td
>
879 <td width
="60" class="left top" ><?php
echo htmlspecialchars( xl('MSP Code'), ENT_QUOTES
) ?
></td
>
880 <td width
="40" class="left top" ><?php
echo htmlspecialchars( xl('Resn'), ENT_QUOTES
) ?
></td
>
881 <td width
="110" class="left top right" ><?php
echo htmlspecialchars( xl('Follow Up Reason'), ENT_QUOTES
) ?
></td
>
885 while ($RowSearch = sqlFetchArray($ResultSearch))
889 $ServiceDateArray=explode(' ',$RowSearch['date']);
890 $ServiceDate=oeFormatShortDate($ServiceDateArray[0]);
891 $Codetype=$RowSearch['code_type'];
892 $Code=$RowSearch['code'];
893 $Modifier =$RowSearch['modifier'];
895 $ModifierString=", $Modifier";
898 $Fee=$RowSearch['fee'];
899 $Encounter=$RowSearch['encounter'];
901 $resPayer = sqlStatement("SELECT payer_type from ar_activity where session_id ='$payment_id' and
902 pid ='$PId' and encounter ='$Encounter' and code_type='$Codetype' and code='$Code' and modifier='$Modifier' ");
903 $rowPayer = sqlFetchArray($resPayer);
904 $Ins=$rowPayer['payer_type'];
906 //Always associating the copay to a particular charge.
907 $BillingId=$RowSearch['id'];
908 $resId = sqlStatement("SELECT id FROM billing where code_type!='ICD9' and code_type!='COPAY' and
909 pid ='$PId' and encounter ='$Encounter' and billing.activity!=0 order by id");
910 $rowId = sqlFetchArray($resId);
913 if($BillingId!=$Id)//multiple cpt in single encounter
919 $resCopay = sqlStatement("SELECT sum(fee) as copay FROM billing where
920 code_type='COPAY' and pid ='$PId' and encounter ='$Encounter' and billing.activity!=0");
921 $rowCopay = sqlFetchArray($resCopay);
922 $Copay=$rowCopay['copay']*-1;
924 $resMoneyGot = sqlStatement("SELECT sum(pay_amount) as PatientPay FROM ar_activity where
925 pid ='$PId' and encounter ='$Encounter' and payer_type=0 and account_code='PCP'");//new fees screen copay gives account_code='PCP'
926 $rowMoneyGot = sqlFetchArray($resMoneyGot);
927 $PatientPay=$rowMoneyGot['PatientPay'];
929 $Copay=$Copay+
$PatientPay;
932 //For calculating Remainder
935 $resMoneyGot = sqlStatement("SELECT sum(pay_amount) as MoneyGot FROM ar_activity where
936 pid ='$PId' and code_type='$Codetype' and code='$Code' and modifier='$Modifier' and encounter ='$Encounter' and !(payer_type=0 and
937 account_code='PCP')");
938 //new fees screen copay gives account_code='PCP'
939 $rowMoneyGot = sqlFetchArray($resMoneyGot);
940 $MoneyGot=$rowMoneyGot['MoneyGot'];
942 $resMoneyAdjusted = sqlStatement("SELECT sum(adj_amount) as MoneyAdjusted FROM ar_activity where
943 pid ='$PId' and code_type='$Codetype' and code='$Code' and modifier='$Modifier' and encounter ='$Encounter'");
944 $rowMoneyAdjusted = sqlFetchArray($resMoneyAdjusted);
945 $MoneyAdjusted=$rowMoneyAdjusted['MoneyAdjusted'];
947 else//Fetch till that much got
949 //Fetch the HIGHEST sequence_no till this session.
950 //Used maily in the case if primary/others pays once more.
951 $resSequence = sqlStatement("SELECT sequence_no from ar_activity where session_id ='$payment_id' and
952 pid ='$PId' and encounter ='$Encounter' order by sequence_no desc ");
953 $rowSequence = sqlFetchArray($resSequence);
954 $Sequence=$rowSequence['sequence_no'];
956 $resMoneyGot = sqlStatement("SELECT sum(pay_amount) as MoneyGot FROM ar_activity where
957 pid ='$PId' and code_type='$Codetype' and code='$Code' and modifier='$Modifier' and encounter ='$Encounter' and
958 payer_type > 0 and payer_type <='$Ins' and sequence_no<='$Sequence'");
959 $rowMoneyGot = sqlFetchArray($resMoneyGot);
960 $MoneyGot=$rowMoneyGot['MoneyGot'];
962 $resMoneyAdjusted = sqlStatement("SELECT sum(adj_amount) as MoneyAdjusted FROM ar_activity where
963 pid ='$PId' and code_type='$Codetype' and code='$Code' and modifier='$Modifier' and encounter ='$Encounter' and
964 payer_type > 0 and payer_type <='$Ins' and sequence_no<='$Sequence'");
965 $rowMoneyAdjusted = sqlFetchArray($resMoneyAdjusted);
966 $MoneyAdjusted=$rowMoneyAdjusted['MoneyAdjusted'];
968 $Remainder=$Fee-$Copay-$MoneyGot-$MoneyAdjusted;
970 //For calculating RemainderJS.Used while restoring back the values.
972 {//Got just before Patient
973 $resMoneyGot = sqlStatement("SELECT sum(pay_amount) as MoneyGot FROM ar_activity where
974 pid ='$PId' and code_type='$Codetype' and code='$Code' and modifier='$Modifier' and encounter ='$Encounter' and payer_type !=0");
975 $rowMoneyGot = sqlFetchArray($resMoneyGot);
976 $MoneyGot=$rowMoneyGot['MoneyGot'];
978 $resMoneyAdjusted = sqlStatement("SELECT sum(adj_amount) as MoneyAdjusted FROM ar_activity where
979 pid ='$PId' and code_type='$Codetype' and code='$Code' and modifier='$Modifier' and encounter ='$Encounter' and payer_type !=0");
980 $rowMoneyAdjusted = sqlFetchArray($resMoneyAdjusted);
981 $MoneyAdjusted=$rowMoneyAdjusted['MoneyAdjusted'];
984 {//Got just before the previous
985 //Fetch the LOWEST sequence_no till this session.
986 //Used maily in the case if primary/others pays once more.
987 $resSequence = sqlStatement("SELECT sequence_no from ar_activity where session_id ='$payment_id' and
988 pid ='$PId' and encounter ='$Encounter' order by sequence_no ");
989 $rowSequence = sqlFetchArray($resSequence);
990 $Sequence=$rowSequence['sequence_no'];
992 $resMoneyGot = sqlStatement("SELECT sum(pay_amount) as MoneyGot FROM ar_activity where
993 pid ='$PId' and code_type='$Codetype' and code='$Code' and modifier='$Modifier' and encounter ='$Encounter'
994 and payer_type > 0 and payer_type <='$Ins' and sequence_no<'$Sequence'");
995 $rowMoneyGot = sqlFetchArray($resMoneyGot);
996 $MoneyGot=$rowMoneyGot['MoneyGot'];
998 $resMoneyAdjusted = sqlStatement("SELECT sum(adj_amount) as MoneyAdjusted FROM ar_activity where
999 pid ='$PId' and code_type='$Codetype' and code='$Code' and modifier='$Modifier' and encounter ='$Encounter'
1000 and payer_type <='$Ins' and sequence_no<'$Sequence' ");
1001 $rowMoneyAdjusted = sqlFetchArray($resMoneyAdjusted);
1002 $MoneyAdjusted=$rowMoneyAdjusted['MoneyAdjusted'];
1004 //Stored in hidden so that can be used while restoring back the values.
1005 $RemainderJS=$Fee-$Copay-$MoneyGot-$MoneyAdjusted;
1007 $resPayment = sqlStatement("SELECT pay_amount from ar_activity where session_id ='$payment_id' and
1008 pid ='$PId' and encounter ='$Encounter' and code_type='$Codetype' and code='$Code' and modifier='$Modifier' and pay_amount>0");
1009 $rowPayment = sqlFetchArray($resPayment);
1010 $PaymentDB=$rowPayment['pay_amount']*1;
1011 $PaymentDB=$PaymentDB == 0 ?
'' : $PaymentDB;
1013 $resPayment = sqlStatement("SELECT pay_amount from ar_activity where session_id ='$payment_id' and
1014 pid ='$PId' and encounter ='$Encounter' and code_type='$Codetype' and code='$Code' and modifier='$Modifier' and pay_amount<0");
1015 $rowPayment = sqlFetchArray($resPayment);
1016 $TakebackDB=$rowPayment['pay_amount']*-1;
1017 $TakebackDB=$TakebackDB == 0 ?
'' : $TakebackDB;
1019 $resPayment = sqlStatement("SELECT adj_amount from ar_activity where session_id ='$payment_id' and
1020 pid ='$PId' and encounter ='$Encounter' and code_type='$Codetype' and code='$Code' and modifier='$Modifier' and adj_amount!=0");
1021 $rowPayment = sqlFetchArray($resPayment);
1022 $AdjAmountDB=$rowPayment['adj_amount']*1;
1023 $AdjAmountDB=$AdjAmountDB == 0 ?
'' : $AdjAmountDB;
1025 $resPayment = sqlStatement("SELECT memo from ar_activity where session_id ='$payment_id' and
1026 pid ='$PId' and encounter ='$Encounter' and code_type='$Codetype' and code='$Code' and modifier='$Modifier' and (memo like 'Deductable%' OR memo like 'Deductible%')");
1027 $rowPayment = sqlFetchArray($resPayment);
1028 $DeductibleDB=$rowPayment['memo'];
1029 $DeductibleDB=str_replace('Deductable $','',$DeductibleDB);
1030 $DeductibleDB=str_replace('Deductible $','',$DeductibleDB);
1032 $resPayment = sqlStatement("SELECT follow_up,follow_up_note from ar_activity where session_id ='$payment_id' and
1033 pid ='$PId' and encounter ='$Encounter' and code_type='$Codetype' and code='$Code' and modifier='$Modifier' and follow_up = 'y'");
1034 $rowPayment = sqlFetchArray($resPayment);
1035 $FollowUpDB=$rowPayment['follow_up'];
1036 $FollowUpReasonDB=$rowPayment['follow_up_note'];
1038 $resPayment = sqlStatement("SELECT reason_code from ar_activity where session_id ='$payment_id' and
1039 pid ='$PId' and encounter ='$Encounter' and code_type='$Codetype' and code='$Code' and modifier='$Modifier'");
1040 $rowPayment = sqlFetchArray($resPayment);
1041 $ReasonCodeDB=$rowPayment['reason_code'];
1045 $AllowedDB=number_format($Fee-$AdjAmountDB,2);
1051 $AllowedDB=$AllowedDB == 0 ?
'' : $AllowedDB;
1053 if($CountIndex==$TotalRows)
1055 $StringClass=' bottom left top ';
1059 $StringClass=' left top ';
1078 $paymenttot=$paymenttot+
$PaymentDB;
1079 $adjamttot=$adjamttot+
$AdjAmountDB;
1080 $deductibletot=$deductibletot+
$DeductibleDB;
1081 $takebacktot=$takebacktot+
$TakebackDB;
1082 $allowedtot=$allowedtot+
$AllowedDB;
1084 <tr
class="text" bgcolor
='<?php echo $bgcolor; ?>' id
="trCharges<?php echo $CountIndex; ?>">
1085 <td align
="left" class="<?php echo $StringClass; ?>" ><a href
="#" onClick
="javascript:return DeletePaymentDistribution('<?php echo htmlspecialchars($payment_id.'_'.$PId.'_'.$Encounter.'_'.$Code.'_'.$Modifier.'_'.$Codetype); ?>');" ><img src
="../pic/Delete.gif" border
="0"/></a
></td
>
1086 <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
>
1087 <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
>
1088 <td
class="<?php echo $StringClass; ?>" ><?php
echo htmlspecialchars($ServiceDate); ?
></td
>
1089 <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
>
1090 <td
class="<?php echo $StringClass; ?>" ><input name
="HiddenCodetype<?php echo $CountIndex; ?>" value
="<?php echo htmlspecialchars($Codetype); ?>" type
="hidden"/><input name
="HiddenCode<?php echo $CountIndex; ?>" value
="<?php echo htmlspecialchars($Code); ?>" type
="hidden"/><?php
echo htmlspecialchars($Codetype."-".$Code.$ModifierString); ?
><input name
="HiddenModifier<?php echo $CountIndex; ?>" value
="<?php echo htmlspecialchars($Modifier); ?>" type
="hidden"/></td
>
1091 <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
>
1092 <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
>
1093 <td align
="right" id
="RemainderTd<?php echo $CountIndex; ?>" class="<?php echo $StringClass; ?>" ><?php
echo htmlspecialchars(round($Remainder,2)); ?
></td
>
1094 <input name
="HiddenRemainderTd<?php echo $CountIndex; ?>" id
="HiddenRemainderTd<?php echo $CountIndex; ?>" value
="<?php echo htmlspecialchars(round($RemainderJS,2)); ?>" type
="hidden"/>
1095 <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
>
1096 <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
>
1097 <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
>
1098 <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
>
1099 <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
>
1100 <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
>
1101 <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
>
1102 <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
>
1107 }//while ($RowSearch = sqlFetchArray($ResultSearch))
1110 }//if(sqlNumRows($ResultSearch)>0)
1112 }while ($RowSearchSub = sqlFetchArray($ResultSearchSub));
1117 <td align
="left" colspan
="9"> 
;</td
>
1118 <td
class="left bottom" bgcolor
="#6699FF" id
="allowtotal" align
="right" ><?php
echo htmlspecialchars(number_format($allowedtot,2)); ?
></td
>
1119 <td
class="left bottom" bgcolor
="#6699FF" id
="paymenttotal" align
="right" ><?php
echo htmlspecialchars(number_format($paymenttot,2)); ?
></td
>
1120 <td
class="left bottom" bgcolor
="#6699FF" id
="AdjAmounttotal" align
="right" ><?php
echo htmlspecialchars(number_format($adjamttot,2)); ?
></td
>
1121 <td
class="left bottom" bgcolor
="#6699FF" id
="deductibletotal" align
="right"><?php
echo htmlspecialchars(number_format($deductibletot,2)); ?
></td
>
1122 <td
class="left bottom right" bgcolor
="#6699FF" id
="takebacktotal" align
="right"><?php
echo htmlspecialchars(number_format($takebacktot,2)); ?
></td
>
1123 <td align
="center"> 
;</td
>
1124 <td align
="center"> 
;</td
>
1134 }//if($RowSearchSub = sqlFetchArray($ResultSearchSub))
1138 <td colspan
="13" align
="left" >
1140 require_once("payment_pat_sel.inc.php"); //Patient ajax section and listing of charges.
1145 <td colspan
="13" align
="left" >
1146 <table border
="0" cellspacing
="0" cellpadding
="0" width
="217" align
="center">
1153 <td width
="110"><a href
="#" onClick
="javascript:return ModifyPayments();" class="css_button"><span
><?php
echo htmlspecialchars( xl('Modify Payments'), ENT_QUOTES
);?
></span
></a
>
1155 <td width
="107"><a href
="#" onClick
="javascript:return FinishPayments();" class="css_button"><span
><?php
echo htmlspecialchars( xl('Finish Payments'), ENT_QUOTES
);?
></span
></a
>
1161 }//if($payment_id*1>0)
1167 <input type
="hidden" name
="hidden_patient_code" id
="hidden_patient_code" value
="<?php echo htmlspecialchars($hidden_patient_code);?>"/>
1168 <input type
='hidden' name
='mode' id
='mode' value
='' />
1169 <input type
='hidden' name
='ajax_mode' id
='ajax_mode' value
='' />
1170 <input type
="hidden" name
="after_value" id
="after_value" value
="<?php echo htmlspecialchars($_POST["mode
"]);?>"/>
1171 <input type
="hidden" name
="payment_id" id
="payment_id" value
="<?php echo htmlspecialchars($payment_id);?>"/>
1172 <input type
="hidden" name
="hidden_type_code" id
="hidden_type_code" value
="<?php echo htmlspecialchars($TypeCode);?>"/>
1173 <input type
='hidden' name
='global_amount' id
='global_amount' value
='' />
1174 <input type
='hidden' name
='DeletePaymentDistributionId' id
='DeletePaymentDistributionId' value
='' />
1175 <input type
="hidden" name
="ActionStatus" id
="ActionStatus" value
="<?php echo htmlspecialchars($Message);?>"/>
1176 <input type
='hidden' name
='CountIndexAbove' id
='CountIndexAbove' value
='<?php echo htmlspecialchars($CountIndexAbove*1);?>' />
1177 <input type
='hidden' name
='CountIndexBelow' id
='CountIndexBelow' value
='<?php echo htmlspecialchars($CountIndexBelow*1);?>' />
1178 <input type
="hidden" name
="ParentPage" id
="ParentPage" value
="<?php echo htmlspecialchars($_REQUEST['ParentPage']);?>"/>