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/formatting.inc.php");
43 require_once("$srcdir/payment.inc.php");
44 //===============================================================================
45 $screen='edit_payment';
46 //===============================================================================
47 // deletion of payment distribution code
48 //===============================================================================
49 if (isset($_POST["mode"]))
51 if ($_POST["mode"] == "DeletePaymentDistribution")
53 $DeletePaymentDistributionId=trim(formData('DeletePaymentDistributionId' ));
54 $DeletePaymentDistributionIdArray=explode('_',$DeletePaymentDistributionId);
55 $payment_id=$DeletePaymentDistributionIdArray[0];
56 $PId=$DeletePaymentDistributionIdArray[1];
57 $Encounter=$DeletePaymentDistributionIdArray[2];
58 $Code=$DeletePaymentDistributionIdArray[3];
59 $Modifier=$DeletePaymentDistributionIdArray[4];
60 $Codetype=$DeletePaymentDistributionIdArray[5];
61 //delete and log that action
62 row_delete("ar_activity", "session_id ='$payment_id' and pid ='$PId' AND " .
63 "encounter='$Encounter' and code_type='$Codetype' and code='$Code' and modifier='$Modifier'");
66 $_POST["mode"] = "searchdatabase";
69 //===============================================================================
70 //Modify Payment Code.
71 //===============================================================================
72 if (isset($_POST["mode"]))
74 if ($_POST["mode"] == "ModifyPayments" ||
$_POST["mode"] == "FinishPayments")
76 $payment_id=$_REQUEST['payment_id'];
78 //===============================================================================
79 if(trim(formData('type_name' ))=='insurance')
81 $QueryPart="payer_id = '" . trim(formData('hidden_type_code' )) .
82 "', patient_id = '" . 0 ;
84 elseif(trim(formData('type_name' ))=='patient')
86 $QueryPart="payer_id = '" . 0 .
87 "', patient_id = '" . trim(formData('hidden_type_code' )) ;
89 $user_id=$_SESSION['authUserID'];
91 $modified_time = date('Y-m-d H:i:s');
92 $check_date=DateToYYYYMMDD(formData('check_date'));
93 $deposit_date=DateToYYYYMMDD(formData('deposit_date'));
94 $post_to_date=DateToYYYYMMDD(formData('post_to_date'));
96 $post_to_date=date('Y-m-d');
97 if(formData('deposit_date')=='')
98 $deposit_date=$post_to_date;
100 sqlStatement("update ar_session set " .
102 "', user_id = '" . trim($user_id ) .
103 "', closed = '" . trim($closed ) .
104 "', reference = '" . trim(formData('check_number' )) .
105 "', check_date = '" . trim($check_date ) .
106 "', deposit_date = '" . trim($deposit_date ) .
107 "', pay_total = '" . trim(formData('payment_amount')) .
108 "', modified_time = '" . trim($modified_time ) .
109 "', payment_type = '" . trim(formData('type_name' )) .
110 "', description = '" . trim(formData('description' )) .
111 "', adjustment_code = '" . trim(formData('adjustment_code' )) .
112 "', post_to_date = '" . trim($post_to_date ) .
113 "', payment_method = '" . trim(formData('payment_method' )) .
114 "' where session_id='$payment_id'");
115 //===============================================================================
116 $CountIndexAbove=$_REQUEST['CountIndexAbove'];
117 $CountIndexBelow=$_REQUEST['CountIndexBelow'];
118 $hidden_patient_code=$_REQUEST['hidden_patient_code'];
119 $user_id=$_SESSION['authUserID'];
120 $created_time = date('Y-m-d H:i:s');
121 //==================================================================
123 //It is done with out deleting any old entries.
124 //==================================================================
125 for($CountRow=1;$CountRow<=$CountIndexAbove;$CountRow++
)
127 if (isset($_POST["HiddenEncounter$CountRow"]))
129 if (isset($_POST["Payment$CountRow"]) && $_POST["Payment$CountRow"]*1>0)
131 if(trim(formData('type_name' ))=='insurance')
133 if(trim(formData("HiddenIns$CountRow" ))==1)
137 if(trim(formData("HiddenIns$CountRow" ))==2)
141 if(trim(formData("HiddenIns$CountRow" ))==3)
146 elseif(trim(formData('type_name' ))=='patient')
150 $resPayment = sqlStatement("SELECT * from ar_activity " .
151 " where session_id ='$payment_id' and pid ='" . trim(formData("HiddenPId$CountRow" )) .
152 "' and encounter ='" . trim(formData("HiddenEncounter$CountRow" )) .
153 "' and code_type ='" . trim(formData("HiddenCodetype$CountRow" )) .
154 "' and code ='" . trim(formData("HiddenCode$CountRow" )) .
155 "' and modifier ='" . trim(formData("HiddenModifier$CountRow" )) .
156 "' and pay_amount>0");
157 if(sqlNumRows($resPayment)>0)
159 sqlStatement("update ar_activity set " .
160 " post_user = '" . trim($user_id ) .
161 "', modified_time = '" . trim($created_time ) .
162 "', pay_amount = '" . trim(formData("Payment$CountRow" )) .
163 "', account_code = '" . "$AccountCode" .
164 "', payer_type = '" . trim(formData("HiddenIns$CountRow" )) .
165 "', reason_code = '" . trim(formData("ReasonCode$CountRow" )) .
166 "' where session_id ='$payment_id' and pid ='" . trim(formData("HiddenPId$CountRow" )) .
167 "' and encounter ='" . trim(formData("HiddenEncounter$CountRow" )) .
168 "' and code_type ='" . trim(formData("HiddenCodetype$CountRow" )) .
169 "' and code ='" . trim(formData("HiddenCode$CountRow" )) .
170 "' and modifier ='" . trim(formData("HiddenModifier$CountRow" )) .
171 "' and pay_amount>0");
176 $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" ))));
177 sqlStatement("insert into ar_activity set " .
178 "pid = '" . trim(formData("HiddenPId$CountRow" )) .
179 "', encounter = '" . trim(formData("HiddenEncounter$CountRow" )) .
180 "', sequence_no = '" . $sequence_no['increment'] .
181 "', code_type = '" . trim(formData("HiddenCodetype$CountRow" )) .
182 "', code = '" . trim(formData("HiddenCode$CountRow" )) .
183 "', modifier = '" . trim(formData("HiddenModifier$CountRow" )) .
184 "', payer_type = '" . trim(formData("HiddenIns$CountRow" )) .
185 "', reason_code = '" . trim(formData("ReasonCode$CountRow" )) .
186 "', post_time = '" . trim($created_time ) .
187 "', post_user = '" . trim($user_id ) .
188 "', session_id = '" . trim(formData('payment_id')) .
189 "', modified_time = '" . trim($created_time ) .
190 "', pay_amount = '" . trim(formData("Payment$CountRow" )) .
191 "', adj_amount = '" . 0 .
192 "', account_code = '" . "$AccountCode" .
199 sqlStatement("delete from ar_activity " .
200 " where session_id ='$payment_id' and pid ='" . trim(formData("HiddenPId$CountRow" )) .
201 "' and encounter ='" . trim(formData("HiddenEncounter$CountRow" )) .
202 "' and code_type ='" . trim(formData("HiddenCodetype$CountRow" )) .
203 "' and code ='" . trim(formData("HiddenCode$CountRow" )) .
204 "' and modifier ='" . trim(formData("HiddenModifier$CountRow" )) .
205 "' and pay_amount>0");
207 //==============================================================================================================================
208 if (isset($_POST["AdjAmount$CountRow"]) && $_POST["AdjAmount$CountRow"]*1!=0)
210 if(trim(formData('type_name' ))=='insurance')
212 $AdjustString="Ins adjust Ins".trim(formData("HiddenIns$CountRow" ));
215 elseif(trim(formData('type_name' ))=='patient')
217 $AdjustString="Pt adjust";
220 $resPayment = sqlStatement("SELECT * from ar_activity " .
221 " where session_id ='$payment_id' and pid ='" . trim(formData("HiddenPId$CountRow" )) .
222 "' and encounter ='" . trim(formData("HiddenEncounter$CountRow" )) .
223 "' and code_type ='" . trim(formData("HiddenCodetype$CountRow" )) .
224 "' and code ='" . trim(formData("HiddenCode$CountRow" )) .
225 "' and modifier ='" . trim(formData("HiddenModifier$CountRow" )) .
226 "' and adj_amount!=0");
227 if(sqlNumRows($resPayment)>0)
229 sqlStatement("update ar_activity set " .
230 " post_user = '" . trim($user_id ) .
231 "', modified_time = '" . trim($created_time ) .
232 "', adj_amount = '" . trim(formData("AdjAmount$CountRow" )) .
233 "', memo = '" . "$AdjustString" .
234 "', account_code = '" . "$AccountCode" .
235 "', payer_type = '" . trim(formData("HiddenIns$CountRow" )) .
236 "' where session_id ='$payment_id' and pid ='" . trim(formData("HiddenPId$CountRow" )) .
237 "' and encounter ='" . trim(formData("HiddenEncounter$CountRow" )) .
238 "' and code_type ='" . trim(formData("HiddenCodetype$CountRow" )) .
239 "' and code ='" . trim(formData("HiddenCode$CountRow" )) .
240 "' and modifier ='" . trim(formData("HiddenModifier$CountRow" )) .
241 "' and adj_amount!=0");
246 $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" ))));
247 sqlStatement("insert into ar_activity set " .
248 "pid = '" . trim(formData("HiddenPId$CountRow" )) .
249 "', encounter = '" . trim(formData("HiddenEncounter$CountRow" )) .
250 "', sequence_no = '" . $sequence_no['increment'] .
251 "', code_type = '" . trim(formData("HiddenCodetype$CountRow" )) .
252 "', code = '" . trim(formData("HiddenCode$CountRow" )) .
253 "', modifier = '" . trim(formData("HiddenModifier$CountRow" )) .
254 "', payer_type = '" . trim(formData("HiddenIns$CountRow" )) .
255 "', post_time = '" . trim($created_time ) .
256 "', post_user = '" . trim($user_id ) .
257 "', session_id = '" . trim(formData('payment_id')) .
258 "', modified_time = '" . trim($created_time ) .
259 "', pay_amount = '" . 0 .
260 "', adj_amount = '" . trim(formData("AdjAmount$CountRow" )) .
261 "', memo = '" . "$AdjustString" .
262 "', account_code = '" . "$AccountCode" .
270 sqlStatement("delete from ar_activity " .
271 " where session_id ='$payment_id' and pid ='" . trim(formData("HiddenPId$CountRow" )) .
272 "' and encounter ='" . trim(formData("HiddenEncounter$CountRow" )) .
273 "' and code_type ='" . trim(formData("HiddenCodetype$CountRow" )) .
274 "' and code ='" . trim(formData("HiddenCode$CountRow" )) .
275 "' and modifier ='" . trim(formData("HiddenModifier$CountRow" )) .
276 "' and adj_amount!=0");
278 //==============================================================================================================================
279 if (isset($_POST["Deductible$CountRow"]) && $_POST["Deductible$CountRow"]*1>0)
281 $resPayment = sqlStatement("SELECT * from ar_activity " .
282 " where session_id ='$payment_id' and pid ='" . trim(formData("HiddenPId$CountRow" )) .
283 "' and encounter ='" . trim(formData("HiddenEncounter$CountRow" )) .
284 "' and code_type ='" . trim(formData("HiddenCodetype$CountRow" )) .
285 "' and code ='" . trim(formData("HiddenCode$CountRow" )) .
286 "' and modifier ='" . trim(formData("HiddenModifier$CountRow" )) .
287 "' and (memo like 'Deductable%' OR memo like 'Deductible%')");
288 if(sqlNumRows($resPayment)>0)
290 sqlStatement("update ar_activity set " .
291 " post_user = '" . trim($user_id ) .
292 "', modified_time = '" . trim($created_time ) .
293 "', memo = '" . "Deductible $".trim(formData("Deductible$CountRow" )) .
294 "', account_code = '" . "Deduct" .
295 "', payer_type = '" . trim(formData("HiddenIns$CountRow" )) .
296 "' where session_id ='$payment_id' and pid ='" . trim(formData("HiddenPId$CountRow" )) .
297 "' and encounter ='" . trim(formData("HiddenEncounter$CountRow" )) .
298 "' and code_type ='" . trim(formData("HiddenCodetype$CountRow" )) .
299 "' and code ='" . trim(formData("HiddenCode$CountRow" )) .
300 "' and modifier ='" . trim(formData("HiddenModifier$CountRow" )) .
301 "' and (memo like 'Deductable%' OR memo like 'Deductible%')");
306 $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"))));
307 sqlStatement("insert into ar_activity set " .
308 "pid = '" . trim(formData("HiddenPId$CountRow" )) .
309 "', encounter = '" . trim(formData("HiddenEncounter$CountRow" )) .
310 "', sequence_no = '" . $sequence_no['increment'] .
311 "', code_type = '" . trim(formData("HiddenCodetype$CountRow" )) .
312 "', code = '" . trim(formData("HiddenCode$CountRow" )) .
313 "', modifier = '" . trim(formData("HiddenModifier$CountRow" )) .
314 "', payer_type = '" . trim(formData("HiddenIns$CountRow" )) .
315 "', post_time = '" . trim($created_time ) .
316 "', post_user = '" . trim($user_id ) .
317 "', session_id = '" . trim(formData('payment_id')) .
318 "', modified_time = '" . trim($created_time ) .
319 "', pay_amount = '" . 0 .
320 "', adj_amount = '" . 0 .
321 "', memo = '" . "Deductible $".trim(formData("Deductible$CountRow" )) .
322 "', account_code = '" . "Deduct" .
329 sqlStatement("delete from ar_activity " .
330 " where session_id ='$payment_id' and pid ='" . trim(formData("HiddenPId$CountRow" )) .
331 "' and encounter ='" . trim(formData("HiddenEncounter$CountRow" )) .
332 "' and code_type ='" . trim(formData("HiddenCodetype$CountRow" )) .
333 "' and code ='" . trim(formData("HiddenCode$CountRow" )) .
334 "' and modifier ='" . trim(formData("HiddenModifier$CountRow" )) .
335 "' and (memo like 'Deductable%' OR memo like 'Deductible%')");
337 //==============================================================================================================================
338 if (isset($_POST["Takeback$CountRow"]) && $_POST["Takeback$CountRow"]*1>0)
340 $resPayment = sqlStatement("SELECT * from ar_activity " .
341 " where session_id ='$payment_id' and pid ='" . trim(formData("HiddenPId$CountRow" )) .
342 "' and encounter ='" . trim(formData("HiddenEncounter$CountRow" )) .
343 "' and code_type ='" . trim(formData("HiddenCodetype$CountRow" )) .
344 "' and code ='" . trim(formData("HiddenCode$CountRow" )) .
345 "' and modifier ='" . trim(formData("HiddenModifier$CountRow" )) .
346 "' and pay_amount < 0");
347 if(sqlNumRows($resPayment)>0)
349 sqlStatement("update ar_activity set " .
350 " post_user = '" . trim($user_id ) .
351 "', modified_time = '" . trim($created_time ) .
352 "', pay_amount = '" . trim(formData("Takeback$CountRow" ))*-1 .
353 "', account_code = '" . "Takeback" .
354 "', payer_type = '" . trim(formData("HiddenIns$CountRow" )) .
355 "' where session_id ='$payment_id' and pid ='" . trim(formData("HiddenPId$CountRow" )) .
356 "' and encounter ='" . trim(formData("HiddenEncounter$CountRow" )) .
357 "' and code_type ='" . trim(formData("HiddenCodetype$CountRow" )) .
358 "' and code ='" . trim(formData("HiddenCode$CountRow" )) .
359 "' and modifier ='" . trim(formData("HiddenModifier$CountRow" )) .
360 "' and pay_amount < 0");
365 $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" ))));
366 sqlStatement("insert into ar_activity set " .
367 "pid = '" . trim(formData("HiddenPId$CountRow" )) .
368 "', encounter = '" . trim(formData("HiddenEncounter$CountRow" )) .
369 "', sequence_no = '" . $sequence_no['increment'] .
370 "', code_type = '" . trim(formData("HiddenCodetype$CountRow" )) .
371 "', code = '" . trim(formData("HiddenCode$CountRow" )) .
372 "', modifier = '" . trim(formData("HiddenModifier$CountRow" )) .
373 "', payer_type = '" . trim(formData("HiddenIns$CountRow" )) .
374 "', post_time = '" . trim($created_time ) .
375 "', post_user = '" . trim($user_id ) .
376 "', session_id = '" . trim(formData('payment_id')) .
377 "', modified_time = '" . trim($created_time ) .
378 "', pay_amount = '" . trim(formData("Takeback$CountRow" ))*-1 .
379 "', adj_amount = '" . 0 .
380 "', account_code = '" . "Takeback" .
387 sqlStatement("delete from ar_activity " .
388 " where session_id ='$payment_id' and pid ='" . trim(formData("HiddenPId$CountRow" )) .
389 "' and encounter ='" . trim(formData("HiddenEncounter$CountRow" )) .
390 "' and code_type ='" . trim(formData("HiddenCodetype$CountRow" )) .
391 "' and code ='" . trim(formData("HiddenCode$CountRow" )) .
392 "' and modifier ='" . trim(formData("HiddenModifier$CountRow" )) .
393 "' and pay_amount < 0");
395 //==============================================================================================================================
396 if (isset($_POST["FollowUp$CountRow"]) && $_POST["FollowUp$CountRow"]=='y')
398 $resPayment = sqlStatement("SELECT * from ar_activity " .
399 " where session_id ='$payment_id' and pid ='" . trim(formData("HiddenPId$CountRow" )) .
400 "' and encounter ='" . trim(formData("HiddenEncounter$CountRow" )) .
401 "' and code_type ='" . trim(formData("HiddenCodetype$CountRow" )) .
402 "' and code ='" . trim(formData("HiddenCode$CountRow" )) .
403 "' and modifier ='" . trim(formData("HiddenModifier$CountRow" )) .
404 "' and follow_up ='y'");
405 if(sqlNumRows($resPayment)>0)
407 sqlStatement("update ar_activity set " .
408 " post_user = '" . trim($user_id ) .
409 "', modified_time = '" . trim($created_time ) .
410 "', follow_up = '" . "y" .
411 "', follow_up_note = '" . trim(formData("FollowUpReason$CountRow" )) .
412 "', payer_type = '" . trim(formData("HiddenIns$CountRow" )) .
413 "' where session_id ='$payment_id' and pid ='" . trim(formData("HiddenPId$CountRow" )) .
414 "' and encounter ='" . trim(formData("HiddenEncounter$CountRow" )) .
415 "' and code_type ='" . trim(formData("HiddenCodetype$CountRow" )) .
416 "' and code ='" . trim(formData("HiddenCode$CountRow" )) .
417 "' and modifier ='" . trim(formData("HiddenModifier$CountRow" )) .
418 "' and follow_up ='y'");
423 $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" ))));
424 sqlStatement("insert into ar_activity set " .
425 "pid = '" . trim(formData("HiddenPId$CountRow" )) .
426 "', encounter = '" . trim(formData("HiddenEncounter$CountRow" )) .
427 "', sequence_no = '" . $sequence_no['increment'] .
428 "', code_type = '" . trim(formData("HiddenCodetype$CountRow" )) .
429 "', code = '" . trim(formData("HiddenCode$CountRow" )) .
430 "', modifier = '" . trim(formData("HiddenModifier$CountRow" )) .
431 "', payer_type = '" . trim(formData("HiddenIns$CountRow" )) .
432 "', post_time = '" . trim($created_time ) .
433 "', post_user = '" . trim($user_id ) .
434 "', session_id = '" . trim(formData('payment_id')) .
435 "', modified_time = '" . trim($created_time ) .
436 "', pay_amount = '" . 0 .
437 "', adj_amount = '" . 0 .
438 "', follow_up = '" . "y" .
439 "', follow_up_note = '" . trim(formData("FollowUpReason$CountRow" )) .
446 sqlStatement("delete from ar_activity " .
447 " where session_id ='$payment_id' and pid ='" . trim(formData("HiddenPId$CountRow" )) .
448 "' and encounter ='" . trim(formData("HiddenEncounter$CountRow" )) .
449 "' and code_type ='" . trim(formData("HiddenCodetype$CountRow" )) .
450 "' and code ='" . trim(formData("HiddenCode$CountRow" )) .
451 "' and modifier ='" . trim(formData("HiddenModifier$CountRow" )) .
452 "' and follow_up ='y'");
454 //==============================================================================================================================
460 //INSERTION of new entries,continuation of modification.
462 for($CountRow=$CountIndexAbove+
1;$CountRow<=$CountIndexAbove+
$CountIndexBelow;$CountRow++
)
464 if (isset($_POST["HiddenEncounter$CountRow"]))
466 DistributionInsert($CountRow,$created_time,$user_id);
471 if($_REQUEST['global_amount']=='yes')
472 sqlStatement("update ar_session set global_amount=".trim(formData("HidUnappliedAmount" ))*1 ." where session_id ='$payment_id'");
473 if($_POST["mode"]=="FinishPayments")
477 $_POST["mode"] = "searchdatabase";
481 //==============================================================================
483 //===============================================================================
484 $payment_id=$payment_id*1 > 0 ?
$payment_id : $_REQUEST['payment_id'];
485 $ResultSearchSub = sqlStatement("SELECT distinct encounter,code_type,code,modifier, pid from ar_activity where session_id ='$payment_id' order by pid,encounter,code,modifier");
486 //==============================================================================
487 $DateFormat=DateFormatRead();
488 //==============================================================================
489 //===============================================================================
494 <?php
if (function_exists('html_header_show')) html_header_show(); ?
>
496 <link rel
="stylesheet" href
="<?php echo $css_header;?>" type
="text/css">
498 <!-- supporting javascript code
-->
500 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/dialog.js?v=<?php echo $v_js_includes; ?>"></script
>
504 <link rel
="stylesheet" href
="<?php echo $css_header;?>" type
="text/css">
505 <link rel
="stylesheet" type
="text/css" href
="../../library/js/fancybox/jquery.fancybox-1.2.6.css" media
="screen" />
506 <style type
="text/css">@import
url(../../library
/dynarch_calendar
.css
);</style
>
507 <script type
="text/javascript" src
="../../library/textformat.js"></script
>
508 <script type
="text/javascript" src
="../../library/dynarch_calendar.js"></script
>
509 <?php
include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?
>
510 <script type
="text/javascript" src
="../../library/dynarch_calendar_setup.js"></script
>
511 <script type
="text/javascript" src
="../../library/dialog.js?v=<?php echo $v_js_includes; ?>"></script
>
512 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-3-2/index.js"></script
>
513 <script type
="text/javascript" src
="../../library/js/fancybox/jquery.fancybox-1.2.6.js"></script
>
514 <script language
='JavaScript'>
517 <?php
include_once("{$GLOBALS['srcdir']}/payment_jav.inc.php"); ?
>
518 <?php
include_once("{$GLOBALS['srcdir']}/ajax/payment_ajax_jav.inc.php"); ?
>
519 <script type
="text/javascript" src
="../../library/js/common.js"></script
>
520 <script LANGUAGE
="javascript" TYPE
="text/javascript">
521 function ModifyPayments()
522 {//Used while modifying the allocation
523 if(!FormValidations())//FormValidations contains the form checks
527 if(CompletlyBlankAbove())//The distribution rows already in the database are checked.
529 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) ?>")
532 if(!CheckPayingEntityAndDistributionPostFor())//Ensures that Insurance payment is distributed under Ins1,Ins2,Ins3 and Patient paymentat under Pat.
536 if(CompletlyBlankBelow())//The newly added distribution rows are checked.
538 alert("<?php echo htmlspecialchars( xl('Fill any of the Below Row.'), ENT_QUOTES) ?>")
541 PostValue
=CheckUnappliedAmount();//Decides TdUnappliedAmount >0, or <0 or =0
544 alert("<?php echo htmlspecialchars( xl('Cannot Modify Payments.Undistributed is Negative.'), ENT_QUOTES) ?>")
547 if(confirm("<?php echo htmlspecialchars( xl('Would you like to Modify Payments?'), ENT_QUOTES) ?>"))
549 document
.getElementById('mode').value
='ModifyPayments';
550 top
.restoreSession();
551 document
.forms
[0].submit();
556 function FinishPayments()
558 if(!FormValidations())//FormValidations contains the form checks
562 if(CompletlyBlankAbove())//The distribution rows already in the database are checked.
564 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) ?>")
567 if(!CheckPayingEntityAndDistributionPostFor())//Ensures that Insurance payment is distributed under Ins1,Ins2,Ins3 and Patient paymentat under Pat.
571 if(CompletlyBlankBelow())//The newly added distribution rows are checked.
573 alert("<?php echo htmlspecialchars( xl('Fill any of the Below Row.'), ENT_QUOTES) ?>")
576 PostValue
=CheckUnappliedAmount();//Decides TdUnappliedAmount >0, or <0 or =0
579 alert("<?php echo htmlspecialchars( xl('Cannot Modify Payments.Undistributed is Negative.'), ENT_QUOTES) ?>")
584 if(confirm("<?php echo htmlspecialchars( xl('Would you like to Modify and Finish Payments?'), ENT_QUOTES) ?>"))
586 UnappliedAmount
=document
.getElementById('TdUnappliedAmount').innerHTML
*1;
587 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) ?>"))
589 document
.getElementById('mode').value
='FinishPayments';
590 document
.getElementById('global_amount').value
='yes';
591 top
.restoreSession();
592 document
.forms
[0].submit();
596 document
.getElementById('mode').value
='FinishPayments';
597 top
.restoreSession();
598 document
.forms
[0].submit();
606 if(confirm("<?php echo htmlspecialchars( xl('Would you like to Modify and Finish Payments?'), ENT_QUOTES) ?>"))
608 document
.getElementById('mode').value
='FinishPayments';
609 top
.restoreSession();
610 document
.forms
[0].submit();
617 function CompletlyBlankAbove()
618 {//The distribution rows already in the database are checked.
619 //It is not allowed to be made completly empty.If needed delete option need to be used.
620 CountIndexAbove
=document
.getElementById('CountIndexAbove').value
*1;
621 for(RowCount
=1;RowCount
<=CountIndexAbove
;RowCount++
)
623 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)
630 function CompletlyBlankBelow()
631 {//The newly added distribution rows are checked.
632 //It is not allowed to be made completly empty.
633 CountIndexAbove
=document
.getElementById('CountIndexAbove').value
*1;
634 CountIndexBelow
=document
.getElementById('CountIndexBelow').value
*1;
635 if(CountIndexBelow
==0)
637 for(RowCount
=CountIndexAbove+
1;RowCount
<=CountIndexAbove+CountIndexBelow
;RowCount++
)
639 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)
648 function OnloadAction()
649 {//Displays message while loading after some action.
650 after_value
=document
.getElementById('ActionStatus').value
;
651 if(after_value
=='Delete')
653 alert("<?php echo htmlspecialchars( xl('Successfully Deleted'), ENT_QUOTES) ?>")
656 if(after_value
=='Modify' || after_value
=='Finish')
658 alert("<?php echo htmlspecialchars( xl('Successfully Modified'), ENT_QUOTES) ?>")
661 after_value
=document
.getElementById('after_value').value
;
662 payment_id
=document
.getElementById('payment_id').value
;
663 if(after_value
=='distribute')
666 else if(after_value
=='new_payment')
668 if(document
.getElementById('TablePatientPortion'))
670 document
.getElementById('TablePatientPortion').style
.display
='none';
672 if(confirm("<?php echo htmlspecialchars( xl('Successfully Saved.Would you like to Distribute?'), ENT_QUOTES) ?>"))
674 if(document
.getElementById('TablePatientPortion'))
676 document
.getElementById('TablePatientPortion').style
.display
='';
682 function DeletePaymentDistribution(DeleteId
)
683 {//Confirms deletion of payment distribution.
684 if(confirm("<?php echo htmlspecialchars( xl('Would you like to Delete Payment Distribution?'), ENT_QUOTES) ?>"))
686 document
.getElementById('mode').value
='DeletePaymentDistribution';
687 document
.getElementById('DeletePaymentDistributionId').value
=DeleteId
;
688 top
.restoreSession();
689 document
.forms
[0].submit();
694 //========================================================================================
696 <script language
="javascript" type
="text/javascript">
697 document
.onclick
=HideTheAjaxDivs
;
700 .class1
{width
:125px
;}
701 .class2
{width
:250px
;}
702 .class3
{width
:100px
;}
703 .bottom
{border
-bottom
:1px solid black
;}
704 .top
{border
-top
:1px solid black
;}
705 .left
{border
-left
:1px solid black
;}
706 .right
{border
-right
:1px solid black
;}
707 #ajax_div_insurance {
714 background
-color
: #FBFDD0;
715 border
: 1px solid
#ccc;
725 background
-color
: #FBFDD0;
726 border
: 1px solid
#ccc;
730 <link rel
="stylesheet" href
="<?php echo $css_header; ?>" type
="text/css">
732 <body
class="body_top" onLoad
="OnloadAction()" >
733 <form name
='new_payment' method
='post' action
="edit_payment.php" onsubmit
='
738 top.restoreSession();return SavePayment();
748 ' style
="display:inline" >
749 <table width
="1024" border
="0" cellspacing
="0" cellpadding
="0">
751 if($_REQUEST['ParentPage']=='new_payment')
755 <td colspan
="3" align
="left"><b
><?php
echo htmlspecialchars( xl('Payments'), ENT_QUOTES
) ?
></b
></td
>
758 <td colspan
="3" align
="left" ></td
>
761 <td colspan
="3" align
="left">
763 <li
class='current'><a href
='new_payment.php'><?php
echo htmlspecialchars( xl('New Payment'), ENT_QUOTES
) ?
></a
></li
>
764 <li
><a href
='search_payments.php'><?php
echo htmlspecialchars( xl('Search Payment'), ENT_QUOTES
) ?
></a
></li
>
765 <li
><a href
='era_payments.php'><?php
echo htmlspecialchars( xl('ERA Posting'), ENT_QUOTES
) ?
></a
></li
>
774 <td colspan
="3" align
="left" ></td
>
780 <td colspan
="3" align
="left" >
787 require_once("payment_master.inc.php"); //Check/cash details are entered here.
800 {//Distribution rows already in the database are displayed.
803 <table width
="1024" border
="0" cellspacing
="0" cellpadding
="10" bgcolor
="#DEDEDE"><tr
><td
>
804 <table width
="1004" border
="0" cellspacing
="0" cellpadding
="0">
807 <td colspan
="13" align
="left" >
810 $resCount = sqlStatement("SELECT distinct encounter,code_type,code,modifier from ar_activity where session_id ='$payment_id' ");
811 $TotalRows=sqlNumRows($resCount);
820 if($RowSearchSub = sqlFetchArray($ResultSearchSub))
825 $PId=$RowSearchSub['pid'];
826 $EncounterMaster=$RowSearchSub['encounter'];
827 // Only use the code_type in the queries below if it is specified in the ar_activity table.
828 // If it is not specified in the ar_activity table, also note it is not requested from the
829 // billing table in below query, thus making it blank in all queries below in this script.
830 $CodetypeMaster=$RowSearchSub['code_type'];
831 $sql_select_part_codetype = "";
832 $sql_where_part_codetype = "";
833 if (!empty($CodetypeMaster)) {
834 $sql_select_part_codetype = "billing.code_type,";
835 $sql_where_part_codetype = "and billing.code_type ='$CodetypeMaster'";
837 $CodeMaster=$RowSearchSub['code'];
838 $ModifierMaster=$RowSearchSub['modifier'];
839 $res = sqlStatement("SELECT fname,lname,mname FROM patient_data where pid ='$PId'");
840 $row = sqlFetchArray($res);
841 $fname=$row['fname'];
842 $lname=$row['lname'];
843 $mname=$row['mname'];
844 $NameDB=$lname.' '.$fname.' '.$mname;
845 $ResultSearch = sqlStatement("SELECT billing.id,last_level_closed,billing.encounter,form_encounter.`date`,$sql_select_part_codetype billing.code,billing.modifier,fee
846 FROM billing ,form_encounter
847 where billing.encounter=form_encounter.encounter and billing.pid=form_encounter.pid and
848 code_type!='ICD9' and code_type!='COPAY' and billing.activity!=0 and
849 form_encounter.pid ='$PId' and billing.pid ='$PId' and billing.encounter ='$EncounterMaster'
850 $sql_where_part_codetype
851 and billing.code ='$CodeMaster'
852 and billing.modifier ='$ModifierMaster'
853 ORDER BY form_encounter.`date`,form_encounter.encounter,billing.code,billing.modifier");
854 if(sqlNumRows($ResultSearch)>0)
860 <table width
="1004" border
="0" cellpadding
="0" cellspacing
="0" align
="center" id
="TableDistributePortion">
861 <tr
class="text" bgcolor
="#dddddd">
862 <td width
="25" class="left top" > 
;</td
>
863 <td width
="144" class="left top" ><?php
echo htmlspecialchars( xl('Patient Name'), ENT_QUOTES
) ?
></td
>
864 <td width
="55" class="left top" ><?php
echo htmlspecialchars( xl('Post For'), ENT_QUOTES
) ?
></td
>
865 <td width
="70" class="left top" ><?php
echo htmlspecialchars( xl('Service Date'), ENT_QUOTES
) ?
></td
>
866 <td width
="50" class="left top" ><?php
echo htmlspecialchars( xl('Encounter'), ENT_QUOTES
) ?
></td
>
867 <td width
="65" class="left top" ><?php
echo htmlspecialchars( xl('Service Code'), ENT_QUOTES
) ?
></td
>
868 <td width
="50" class="left top" ><?php
echo htmlspecialchars( xl('Charge'), ENT_QUOTES
) ?
></td
>
869 <td width
="40" class="left top" ><?php
echo htmlspecialchars( xl('Copay'), ENT_QUOTES
) ?
></td
>
870 <td width
="40" class="left top" ><?php
echo htmlspecialchars( xl('Remdr'), ENT_QUOTES
) ?
></td
>
871 <td width
="60" class="left top" ><?php
echo htmlspecialchars( xl('Allowed(c)'), ENT_QUOTES
) ?
></td
><!-- (c
) means it is calculated
.Not stored one
. -->
872 <td width
="60" class="left top" ><?php
echo htmlspecialchars( xl('Payment'), ENT_QUOTES
) ?
></td
>
873 <td width
="70" class="left top" ><?php
echo htmlspecialchars( xl('Adj Amount'), ENT_QUOTES
) ?
></td
>
874 <td width
="60" class="left top" ><?php
echo htmlspecialchars( xl('Deductible'), ENT_QUOTES
) ?
></td
>
875 <td width
="60" class="left top" ><?php
echo htmlspecialchars( xl('Takeback'), ENT_QUOTES
) ?
></td
>
876 <td width
="60" class="left top" ><?php
echo htmlspecialchars( xl('MSP Code'), ENT_QUOTES
) ?
></td
>
877 <td width
="40" class="left top" ><?php
echo htmlspecialchars( xl('Resn'), ENT_QUOTES
) ?
></td
>
878 <td width
="110" class="left top right" ><?php
echo htmlspecialchars( xl('Follow Up Reason'), ENT_QUOTES
) ?
></td
>
882 while ($RowSearch = sqlFetchArray($ResultSearch))
886 $ServiceDateArray=explode(' ',$RowSearch['date']);
887 $ServiceDate=oeFormatShortDate($ServiceDateArray[0]);
888 $Codetype=$RowSearch['code_type'];
889 $Code=$RowSearch['code'];
890 $Modifier =$RowSearch['modifier'];
892 $ModifierString=", $Modifier";
895 $Fee=$RowSearch['fee'];
896 $Encounter=$RowSearch['encounter'];
898 $resPayer = sqlStatement("SELECT payer_type from ar_activity where session_id ='$payment_id' and
899 pid ='$PId' and encounter ='$Encounter' and code_type='$Codetype' and code='$Code' and modifier='$Modifier' ");
900 $rowPayer = sqlFetchArray($resPayer);
901 $Ins=$rowPayer['payer_type'];
903 //Always associating the copay to a particular charge.
904 $BillingId=$RowSearch['id'];
905 $resId = sqlStatement("SELECT id FROM billing where code_type!='ICD9' and code_type!='COPAY' and
906 pid ='$PId' and encounter ='$Encounter' and billing.activity!=0 order by id");
907 $rowId = sqlFetchArray($resId);
910 if($BillingId!=$Id)//multiple cpt in single encounter
916 $resCopay = sqlStatement("SELECT sum(fee) as copay FROM billing where
917 code_type='COPAY' and pid ='$PId' and encounter ='$Encounter' and billing.activity!=0");
918 $rowCopay = sqlFetchArray($resCopay);
919 $Copay=$rowCopay['copay']*-1;
921 $resMoneyGot = sqlStatement("SELECT sum(pay_amount) as PatientPay FROM ar_activity where
922 pid ='$PId' and encounter ='$Encounter' and payer_type=0 and account_code='PCP'");//new fees screen copay gives account_code='PCP'
923 $rowMoneyGot = sqlFetchArray($resMoneyGot);
924 $PatientPay=$rowMoneyGot['PatientPay'];
926 $Copay=$Copay+
$PatientPay;
929 //For calculating Remainder
932 $resMoneyGot = sqlStatement("SELECT sum(pay_amount) as MoneyGot FROM ar_activity where
933 pid ='$PId' and code_type='$Codetype' and code='$Code' and modifier='$Modifier' and encounter ='$Encounter' and !(payer_type=0 and
934 account_code='PCP')");
935 //new fees screen copay gives account_code='PCP'
936 $rowMoneyGot = sqlFetchArray($resMoneyGot);
937 $MoneyGot=$rowMoneyGot['MoneyGot'];
939 $resMoneyAdjusted = sqlStatement("SELECT sum(adj_amount) as MoneyAdjusted FROM ar_activity where
940 pid ='$PId' and code_type='$Codetype' and code='$Code' and modifier='$Modifier' and encounter ='$Encounter'");
941 $rowMoneyAdjusted = sqlFetchArray($resMoneyAdjusted);
942 $MoneyAdjusted=$rowMoneyAdjusted['MoneyAdjusted'];
944 else//Fetch till that much got
946 //Fetch the HIGHEST sequence_no till this session.
947 //Used maily in the case if primary/others pays once more.
948 $resSequence = sqlStatement("SELECT sequence_no from ar_activity where session_id ='$payment_id' and
949 pid ='$PId' and encounter ='$Encounter' order by sequence_no desc ");
950 $rowSequence = sqlFetchArray($resSequence);
951 $Sequence=$rowSequence['sequence_no'];
953 $resMoneyGot = sqlStatement("SELECT sum(pay_amount) as MoneyGot FROM ar_activity where
954 pid ='$PId' and code_type='$Codetype' and code='$Code' and modifier='$Modifier' and encounter ='$Encounter' and
955 payer_type > 0 and payer_type <='$Ins' and sequence_no<='$Sequence'");
956 $rowMoneyGot = sqlFetchArray($resMoneyGot);
957 $MoneyGot=$rowMoneyGot['MoneyGot'];
959 $resMoneyAdjusted = sqlStatement("SELECT sum(adj_amount) as MoneyAdjusted FROM ar_activity where
960 pid ='$PId' and code_type='$Codetype' and code='$Code' and modifier='$Modifier' and encounter ='$Encounter' and
961 payer_type > 0 and payer_type <='$Ins' and sequence_no<='$Sequence'");
962 $rowMoneyAdjusted = sqlFetchArray($resMoneyAdjusted);
963 $MoneyAdjusted=$rowMoneyAdjusted['MoneyAdjusted'];
965 $Remainder=$Fee-$Copay-$MoneyGot-$MoneyAdjusted;
967 //For calculating RemainderJS.Used while restoring back the values.
969 {//Got just before Patient
970 $resMoneyGot = sqlStatement("SELECT sum(pay_amount) as MoneyGot FROM ar_activity where
971 pid ='$PId' and code_type='$Codetype' and code='$Code' and modifier='$Modifier' and encounter ='$Encounter' and payer_type !=0");
972 $rowMoneyGot = sqlFetchArray($resMoneyGot);
973 $MoneyGot=$rowMoneyGot['MoneyGot'];
975 $resMoneyAdjusted = sqlStatement("SELECT sum(adj_amount) as MoneyAdjusted FROM ar_activity where
976 pid ='$PId' and code_type='$Codetype' and code='$Code' and modifier='$Modifier' and encounter ='$Encounter' and payer_type !=0");
977 $rowMoneyAdjusted = sqlFetchArray($resMoneyAdjusted);
978 $MoneyAdjusted=$rowMoneyAdjusted['MoneyAdjusted'];
981 {//Got just before the previous
982 //Fetch the LOWEST sequence_no till this session.
983 //Used maily in the case if primary/others pays once more.
984 $resSequence = sqlStatement("SELECT sequence_no from ar_activity where session_id ='$payment_id' and
985 pid ='$PId' and encounter ='$Encounter' order by sequence_no ");
986 $rowSequence = sqlFetchArray($resSequence);
987 $Sequence=$rowSequence['sequence_no'];
989 $resMoneyGot = sqlStatement("SELECT sum(pay_amount) as MoneyGot FROM ar_activity where
990 pid ='$PId' and code_type='$Codetype' and code='$Code' and modifier='$Modifier' and encounter ='$Encounter'
991 and payer_type > 0 and payer_type <='$Ins' and sequence_no<'$Sequence'");
992 $rowMoneyGot = sqlFetchArray($resMoneyGot);
993 $MoneyGot=$rowMoneyGot['MoneyGot'];
995 $resMoneyAdjusted = sqlStatement("SELECT sum(adj_amount) as MoneyAdjusted FROM ar_activity where
996 pid ='$PId' and code_type='$Codetype' and code='$Code' and modifier='$Modifier' and encounter ='$Encounter'
997 and payer_type <='$Ins' and sequence_no<'$Sequence' ");
998 $rowMoneyAdjusted = sqlFetchArray($resMoneyAdjusted);
999 $MoneyAdjusted=$rowMoneyAdjusted['MoneyAdjusted'];
1001 //Stored in hidden so that can be used while restoring back the values.
1002 $RemainderJS=$Fee-$Copay-$MoneyGot-$MoneyAdjusted;
1004 $resPayment = sqlStatement("SELECT pay_amount from ar_activity where session_id ='$payment_id' and
1005 pid ='$PId' and encounter ='$Encounter' and code_type='$Codetype' and code='$Code' and modifier='$Modifier' and pay_amount>0");
1006 $rowPayment = sqlFetchArray($resPayment);
1007 $PaymentDB=$rowPayment['pay_amount']*1;
1008 $PaymentDB=$PaymentDB == 0 ?
'' : $PaymentDB;
1010 $resPayment = sqlStatement("SELECT pay_amount from ar_activity where session_id ='$payment_id' and
1011 pid ='$PId' and encounter ='$Encounter' and code_type='$Codetype' and code='$Code' and modifier='$Modifier' and pay_amount<0");
1012 $rowPayment = sqlFetchArray($resPayment);
1013 $TakebackDB=$rowPayment['pay_amount']*-1;
1014 $TakebackDB=$TakebackDB == 0 ?
'' : $TakebackDB;
1016 $resPayment = sqlStatement("SELECT adj_amount from ar_activity where session_id ='$payment_id' and
1017 pid ='$PId' and encounter ='$Encounter' and code_type='$Codetype' and code='$Code' and modifier='$Modifier' and adj_amount!=0");
1018 $rowPayment = sqlFetchArray($resPayment);
1019 $AdjAmountDB=$rowPayment['adj_amount']*1;
1020 $AdjAmountDB=$AdjAmountDB == 0 ?
'' : $AdjAmountDB;
1022 $resPayment = sqlStatement("SELECT memo from ar_activity where session_id ='$payment_id' and
1023 pid ='$PId' and encounter ='$Encounter' and code_type='$Codetype' and code='$Code' and modifier='$Modifier' and (memo like 'Deductable%' OR memo like 'Deductible%')");
1024 $rowPayment = sqlFetchArray($resPayment);
1025 $DeductibleDB=$rowPayment['memo'];
1026 $DeductibleDB=str_replace('Deductable $','',$DeductibleDB);
1027 $DeductibleDB=str_replace('Deductible $','',$DeductibleDB);
1029 $resPayment = sqlStatement("SELECT follow_up,follow_up_note from ar_activity where session_id ='$payment_id' and
1030 pid ='$PId' and encounter ='$Encounter' and code_type='$Codetype' and code='$Code' and modifier='$Modifier' and follow_up = 'y'");
1031 $rowPayment = sqlFetchArray($resPayment);
1032 $FollowUpDB=$rowPayment['follow_up'];
1033 $FollowUpReasonDB=$rowPayment['follow_up_note'];
1035 $resPayment = sqlStatement("SELECT reason_code from ar_activity where session_id ='$payment_id' and
1036 pid ='$PId' and encounter ='$Encounter' and code_type='$Codetype' and code='$Code' and modifier='$Modifier'");
1037 $rowPayment = sqlFetchArray($resPayment);
1038 $ReasonCodeDB=$rowPayment['reason_code'];
1042 $AllowedDB=number_format($Fee-$AdjAmountDB,2);
1048 $AllowedDB=$AllowedDB == 0 ?
'' : $AllowedDB;
1050 if($CountIndex==$TotalRows)
1052 $StringClass=' bottom left top ';
1056 $StringClass=' left top ';
1075 $paymenttot=$paymenttot+
$PaymentDB;
1076 $adjamttot=$adjamttot+
$AdjAmountDB;
1077 $deductibletot=$deductibletot+
$DeductibleDB;
1078 $takebacktot=$takebacktot+
$TakebackDB;
1079 $allowedtot=$allowedtot+
$AllowedDB;
1081 <tr
class="text" bgcolor
='<?php echo $bgcolor; ?>' id
="trCharges<?php echo $CountIndex; ?>">
1082 <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
>
1083 <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
>
1084 <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
>
1085 <td
class="<?php echo $StringClass; ?>" ><?php
echo htmlspecialchars($ServiceDate); ?
></td
>
1086 <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
>
1087 <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
>
1088 <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
>
1089 <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
>
1090 <td align
="right" id
="RemainderTd<?php echo $CountIndex; ?>" class="<?php echo $StringClass; ?>" ><?php
echo htmlspecialchars(round($Remainder,2)); ?
></td
>
1091 <input name
="HiddenRemainderTd<?php echo $CountIndex; ?>" id
="HiddenRemainderTd<?php echo $CountIndex; ?>" value
="<?php echo htmlspecialchars(round($RemainderJS,2)); ?>" type
="hidden"/>
1092 <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
>
1093 <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
>
1094 <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
>
1095 <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
>
1096 <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
>
1097 <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
>
1098 <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
>
1099 <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
>
1104 }//while ($RowSearch = sqlFetchArray($ResultSearch))
1107 }//if(sqlNumRows($ResultSearch)>0)
1109 }while ($RowSearchSub = sqlFetchArray($ResultSearchSub));
1114 <td align
="left" colspan
="9"> 
;</td
>
1115 <td
class="left bottom" bgcolor
="#6699FF" id
="allowtotal" align
="right" ><?php
echo htmlspecialchars(number_format($allowedtot,2)); ?
></td
>
1116 <td
class="left bottom" bgcolor
="#6699FF" id
="paymenttotal" align
="right" ><?php
echo htmlspecialchars(number_format($paymenttot,2)); ?
></td
>
1117 <td
class="left bottom" bgcolor
="#6699FF" id
="AdjAmounttotal" align
="right" ><?php
echo htmlspecialchars(number_format($adjamttot,2)); ?
></td
>
1118 <td
class="left bottom" bgcolor
="#6699FF" id
="deductibletotal" align
="right"><?php
echo htmlspecialchars(number_format($deductibletot,2)); ?
></td
>
1119 <td
class="left bottom right" bgcolor
="#6699FF" id
="takebacktotal" align
="right"><?php
echo htmlspecialchars(number_format($takebacktot,2)); ?
></td
>
1120 <td align
="center"> 
;</td
>
1121 <td align
="center"> 
;</td
>
1131 }//if($RowSearchSub = sqlFetchArray($ResultSearchSub))
1135 <td colspan
="13" align
="left" >
1137 require_once("payment_pat_sel.inc.php"); //Patient ajax section and listing of charges.
1142 <td colspan
="13" align
="left" >
1143 <table border
="0" cellspacing
="0" cellpadding
="0" width
="217" align
="center">
1150 <td width
="110"><a href
="#" onClick
="javascript:return ModifyPayments();" class="css_button"><span
><?php
echo htmlspecialchars( xl('Modify Payments'), ENT_QUOTES
);?
></span
></a
>
1152 <td width
="107"><a href
="#" onClick
="javascript:return FinishPayments();" class="css_button"><span
><?php
echo htmlspecialchars( xl('Finish Payments'), ENT_QUOTES
);?
></span
></a
>
1158 }//if($payment_id*1>0)
1164 <input type
="hidden" name
="hidden_patient_code" id
="hidden_patient_code" value
="<?php echo htmlspecialchars($hidden_patient_code);?>"/>
1165 <input type
='hidden' name
='mode' id
='mode' value
='' />
1166 <input type
='hidden' name
='ajax_mode' id
='ajax_mode' value
='' />
1167 <input type
="hidden" name
="after_value" id
="after_value" value
="<?php echo htmlspecialchars($_POST["mode
"]);?>"/>
1168 <input type
="hidden" name
="payment_id" id
="payment_id" value
="<?php echo htmlspecialchars($payment_id);?>"/>
1169 <input type
="hidden" name
="hidden_type_code" id
="hidden_type_code" value
="<?php echo htmlspecialchars($TypeCode);?>"/>
1170 <input type
='hidden' name
='global_amount' id
='global_amount' value
='' />
1171 <input type
='hidden' name
='DeletePaymentDistributionId' id
='DeletePaymentDistributionId' value
='' />
1172 <input type
="hidden" name
="ActionStatus" id
="ActionStatus" value
="<?php echo htmlspecialchars($Message);?>"/>
1173 <input type
='hidden' name
='CountIndexAbove' id
='CountIndexAbove' value
='<?php echo htmlspecialchars($CountIndexAbove*1);?>' />
1174 <input type
='hidden' name
='CountIndexBelow' id
='CountIndexBelow' value
='<?php echo htmlspecialchars($CountIndexBelow*1);?>' />
1175 <input type
="hidden" name
="ParentPage" id
="ParentPage" value
="<?php echo htmlspecialchars($_REQUEST['ParentPage']);?>"/>