2 // Copyright (C) 2005-2009 Rod Roark <rod@sunsetsystems.com>
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
9 // This provides for manual posting of EOBs. It is invoked from
10 // sl_eob_search.php. For automated (X12 835) remittance posting
11 // see sl_eob_process.php.
13 include_once("../globals.php");
14 include_once("../../library/patient.inc");
15 include_once("../../library/forms.inc");
16 include_once("../../library/sl_eob.inc.php");
17 include_once("../../library/invoice_summary.inc.php");
18 include_once("../../custom/code_types.inc.php");
20 $debug = 0; // set to 1 for debugging mode
22 $INTEGRATED_AR = $GLOBALS['oer_config']['ws_accounting']['enabled'] === 2;
26 // Format money for display.
28 function bucks($amount) {
30 printf("%.2f", $amount);
35 <?
html_header_show();?
>
36 <link rel
=stylesheet href
="<?php echo $css_header;?>" type
="text/css">
37 <title
><?php
xl('EOB Posting - Invoice','e')?
></title
>
38 <script language
="JavaScript">
40 // An insurance radio button is selected.
41 function setins(istr
) {
42 <?php
if (!$INTEGRATED_AR) { ?
>
43 var f
= document
.forms
[0];
44 for (var i
= 0; i
< f
.elements
.length
; ++i
) {
45 var ename
= f
.elements
[i
].name
;
46 if (ename
.indexOf('[src]') < 0) continue;
47 var evalue
= f
.elements
[i
].value
;
48 var tmp
= evalue
.substring(0, 4).toLowerCase();
49 if (tmp
>= 'ins1' && tmp
<= 'ins3')
50 evalue
= evalue
.substring(4);
51 else if (evalue
.substring(0, 2).toLowerCase() == 'pt')
52 evalue
= evalue
.substring(2);
53 while (evalue
.substring(0, 1) == '/')
54 evalue
= evalue
.substring(1);
55 f
.elements
[i
].value
= istr +
'/' + evalue
;
61 // Compute an adjustment that writes off the balance:
62 function writeoff(code
) {
63 var f
= document
.forms
[0];
64 var belement
= f
['form_line[' + code +
'][bal]'];
65 var pelement
= f
['form_line[' + code +
'][pay]'];
66 var aelement
= f
['form_line[' + code +
'][adj]'];
67 var relement
= f
['form_line[' + code +
'][reason]'];
68 var tmp
= belement
.value
- pelement
.value
;
69 aelement
.value
= Number(tmp
).toFixed(2);
70 if (aelement
.value
&& ! relement
.value
) relement
.selectedIndex
= 1;
74 // Onsubmit handler. A good excuse to write some JavaScript.
75 function validate(f
) {
76 for (var i
= 0; i
< f
.elements
.length
; ++i
) {
77 var ename
= f
.elements
[i
].name
;
78 var pfxlen
= ename
.indexOf('[pay]');
79 if (pfxlen
< 0) continue;
80 var pfx
= ename
.substring(0, pfxlen
);
81 var code
= pfx
.substring(pfx
.indexOf('[')+
1, pfxlen
-1);
82 if (f
[pfx+
'[pay]'].value || f
[pfx+
'[adj]'].value
) {
83 <?php
if (!$INTEGRATED_AR) { // source validation not appropriate ?>
84 var srcobj
= f
[pfx+
'[src]'];
85 while (srcobj
.value
.length
) {
86 var tmp
= srcobj
.value
.substring(srcobj
.value
.length
- 1);
87 if (tmp
> ' ' && tmp
!= '/') break;
88 srcobj
.value
= srcobj
.value
.substring(0, srcobj
.value
.length
- 1);
90 var svalue
= srcobj
.value
;
92 alert('<?php xl('Source is missing
for code
','e
') ?>' + code
);
95 var tmp
= svalue
.substring(0, 4).toLowerCase();
96 if (tmp
>= 'ins1' && tmp
<= 'ins3') {
97 svalue
= svalue
.substring(4);
98 } else if (svalue
.substring(0, 2).toLowerCase() == 'pt') {
99 svalue
= svalue
.substring(2);
101 alert('<?php xl('Invalid
or missing payer in source
for code
','e
')?>' + code
);
105 if (svalue
.substring(0, 1) != '/') {
106 alert('<?php xl('Missing slash after payer in source
for code
','e
')?>' + code
);
109 if (false) { // Please keep this, Oakland Clinic wants it. -- Rod
110 tmp
= svalue
.substring(1, 3).toLowerCase();
111 if (tmp
!= 'nm' && tmp
!= 'ci' && tmp
!= 'cp' && tmp
!= 'ne' &&
112 tmp
!= 'it' && tmp
!= 'pf' && tmp
!= 'pp' && tmp
!= 'ok')
114 alert('<?php xl('Invalid source designation
"','e') ?>' + tmp + '<?php xl('" for code
','e
') ?>' + code
);
121 if (! f
[pfx+
'[date]'].value
) {
122 alert('<?php xl('Date is missing
for code
','e
')?>' + code
);
126 if (f
[pfx+
'[pay]'].value
&& isNaN(parseFloat(f
[pfx+
'[pay]'].value
))) {
127 alert('<?php xl('Payment value
for code
','e
') ?>' + code +
'<?php xl(' is not a number
','e
') ?>');
130 if (f
[pfx+
'[adj]'].value
&& isNaN(parseFloat(f
[pfx+
'[adj]'].value
))) {
131 alert('<?php xl('Adjustment value
for code
','e
') ?>' + code +
'<?php xl(' is not a number
','e
') ?>');
134 if (f
[pfx+
'[adj]'].value
&& ! f
[pfx+
'[reason]'].value
) {
135 alert('<?php xl('Please select an adjustment reason
for code
','e
') ?>' + code
);
138 // TBD: validate the date format
145 <body leftmargin
='0' topmargin
='0' marginwidth
='0' marginheight
='0'>
147 $trans_id = 0 +
$_GET['id'];
148 if (! $trans_id) die(xl("You cannot access this page directly."));
150 if ($INTEGRATED_AR) {
151 // In the Integrated A/R case, $trans_id matches form_encounter.id.
152 $ferow = sqlQuery("SELECT e.*, p.fname, p.mname, p.lname " .
153 "FROM form_encounter AS e, patient_data AS p WHERE " .
154 "e.id = '$trans_id' AND p.pid = e.pid");
155 if (empty($ferow)) die("There is no encounter with form_encounter.id = '$trans_id'.");
156 $patient_id = 0 +
$ferow['pid'];
157 $encounter_id = 0 +
$ferow['encounter'];
158 $svcdate = substr($ferow['date'], 0, 10);
159 $form_payer_id = 0 +
$_POST['form_payer_id'];
160 $form_reference = $_POST['form_reference'];
161 $form_check_date = fixDate($_POST['form_check_date'], date('Y-m-d'));
162 $form_deposit_date = fixDate($_POST['form_deposit_date'], $form_check_date);
163 $form_pay_total = 0 +
$_POST['form_pay_total'];
170 if (preg_match('/^Ins(\d)/i', $_POST['form_insurance'], $matches)) {
171 $payer_type = $matches[1];
174 if ($_POST['form_save'] ||
$_POST['form_cancel']) {
175 if ($_POST['form_save']) {
177 echo xl("This module is in test mode. The database will not be changed.",'','<p><b>',"</b><p>\n");
180 if ($INTEGRATED_AR) {
181 $session_id = arGetSession($form_payer_id, $form_reference,
182 $form_check_date, $form_deposit_date, $form_pay_total);
183 // The sl_eob_search page needs its invoice links modified to invoke
184 // javascript to load form parms for all the above and submit.
185 // At the same time that page would be modified to work off the
186 // openemr database exclusively.
187 // And back to the sl_eob_invoice page, I think we may want to move
188 // the source input fields from row level to header level.
192 foreach ($_POST['form_line'] as $code => $cdata) {
193 if (!$INTEGRATED_AR) {
194 $thissrc = trim($cdata['src']);
195 $thisdate = trim($cdata['date']);
197 $thispay = trim($cdata['pay']);
198 $thisadj = trim($cdata['adj']);
199 $thisins = trim($cdata['ins']);
200 $reason = trim($cdata['reason']);
201 if (strpos(strtolower($reason), 'ins') !== false)
202 $reason .= ' ' . $_POST['form_insurance'];
203 if (! $thisins) $thisins = 0;
206 if ($INTEGRATED_AR) {
207 arPostPayment($patient_id, $encounter_id, $session_id,
208 $thispay, $code, $payer_type, $reason, $debug);
210 slPostPayment($trans_id, $thispay, $thisdate, $thissrc, $code, $thisins, $debug);
212 $paytotal +
= $thispay;
215 // Be sure to record adjustment reasons even for zero adjustments.
216 if ($thisadj ||
$reason) {
217 // "To copay" and "To ded'ble" need to become a comment in a zero
218 // adjustment, formatted just like sl_eob_process.php.
219 if (preg_match("/To copay/", $reason)) {
220 $reason = $_POST['form_insurance'] . " coins: $thisadj";
223 else if (preg_match("/To ded'ble/", $reason)) {
224 $reason = $_POST['form_insurance'] . " dedbl: $thisadj";
227 if ($INTEGRATED_AR) {
228 arPostAdjustment($patient_id, $encounter_id, $session_id,
229 $thisadj, $code, $payer_type, $reason, $debug);
231 slPostAdjustment($trans_id, $thisadj, $thisdate, $thissrc, $code, $thisins, $reason, $debug);
236 // Maintain which insurances are marked as finished.
238 if ($INTEGRATED_AR) {
239 $form_done = 0 +
$_POST['form_done'];
240 sqlStatement("UPDATE form_encounter " .
241 "SET last_level_closed = $form_done WHERE " .
242 "pid = '$patient_id' AND encounter = '$encounter_id'");
245 $form_duedate = fixDate($_POST['form_duedate']);
246 $form_notes = trim($_POST['form_notes']);
247 // We use the "Ship Via" field of the invoice to hold these.
249 foreach (array('Ins1', 'Ins2', 'Ins3') as $value) {
250 if ($_POST["form_done_$value"]) {
251 if ($form_eobs) $form_eobs .= ","; else $form_eobs = "Done: ";
252 $form_eobs .= $value;
255 $query = "UPDATE ar SET duedate = '$form_duedate', notes = '$form_notes', " .
256 "shipvia = '$form_eobs' WHERE id = $trans_id";
258 echo $query . "<br>\n";
261 if ($sl_err) die($sl_err);
265 if ($_POST['form_secondary']) {
266 if ($INTEGRATED_AR) {
267 arSetupSecondary($patient_id, $encounter_id, $debug);
269 slSetupSecondary($trans_id, $debug);
273 echo "<script language='JavaScript'>\n";
274 echo " if (opener.document.forms[0].form_amount) {\n";
275 echo " var tmp = opener.document.forms[0].form_amount.value - $paytotal;\n";
276 echo " opener.document.forms[0].form_amount.value = Number(tmp).toFixed(2);\n";
279 echo "<script language='JavaScript'>\n";
281 if ($info_msg) echo " alert('$info_msg');\n";
282 if (! $debug) echo " window.close();\n";
283 echo "</script></body></html>\n";
284 if (!$INTEGRATED_AR) SLClose();
288 if ($INTEGRATED_AR) {
289 /*****************************************************************
290 $ferow = sqlQuery("SELECT e.*, p.fname, p.mname, p.lname " .
291 "FROM form_encounter AS e, patient_data AS p WHERE " .
292 "e.pid = '$patient_id' AND e.encounter = '$encounter_id' AND ".
294 if (empty($ferow)) die("There is no encounter $patient_id.$encounter_id.");
295 $svcdate = substr($ferow['date'], 0, 10);
296 *****************************************************************/
297 // Get invoice charge details.
298 $codes = ar_get_invoice_summary($patient_id, $encounter_id, true);
301 // Get invoice data into $arrow.
302 $arres = SLQuery("select ar.*, customer.name, employee.name as doctor " .
303 "from ar, customer, employee where ar.id = $trans_id and " .
304 "customer.id = ar.customer_id and employee.id = ar.employee_id");
305 if ($sl_err) die($sl_err);
306 $arrow = SLGetRow($arres, 0);
307 if (! $arrow) die(xl("There is no match for invoice id = ") . $trans_id);
309 // Determine the date of service. An 8-digit encounter number is
310 // presumed to be a date of service imported during conversion.
311 // Otherwise look it up in the form_encounter table.
314 list($patient_id, $encounter) = explode(".", $arrow['invnumber']);
315 if (strlen($encounter) == 8) {
316 $svcdate = substr($encounter, 0, 4) . "-" . substr($encounter, 4, 2) .
317 "-" . substr($encounter, 6, 2);
319 else if ($encounter) {
320 $tmp = sqlQuery("SELECT date FROM form_encounter WHERE " .
321 "encounter = $encounter");
322 $svcdate = substr($tmp['date'], 0, 10);
325 // Get invoice charge details.
326 $codes = get_invoice_summary($trans_id, true);
329 $pdrow = sqlQuery("select genericname2, genericval2 " .
330 "from patient_data where pid = '$patient_id' limit 1");
334 <form method
='post' action
='sl_eob_invoice.php?id=<?php echo $trans_id ?>'
335 onsubmit
='return validate(this)'>
337 <table border
='0' cellpadding
='3'>
340 <?php
xl('Patient:','e')?
>
344 if ($INTEGRATED_AR) {
345 echo $ferow['fname'] . ' ' . $ferow['mname'] . ' ' . $ferow['lname'];
352 <td colspan
="2" rowspan
="3">
354 if ($INTEGRATED_AR) {
355 for ($i = 1; $i <= 3; ++
$i) {
356 $payerid = arGetPayerID($patient_id, $svcdate, $i);
358 $tmp = sqlQuery("SELECT name FROM insurance_companies WHERE id = $payerid");
359 echo "Ins$i: " . $tmp['name'] . "<br />";
364 echo " <textarea name='form_notes' cols='50' style='height:100%'>";
365 echo $arrow['notes'];
366 echo "</textarea>\n";
373 <?php
xl('Provider:','e')?
>
377 if ($INTEGRATED_AR) {
378 $tmp = sqlQuery("SELECT fname, mname, lname " .
379 "FROM users WHERE id = " . $ferow['provider_id']);
380 echo $tmp['fname'] . ' ' . $tmp['mname'] . ' ' . $tmp['lname'];
381 $tmp = sqlQuery("SELECT bill_date FROM billing WHERE " .
382 "pid = '$patient_id' AND encounter = '$encounter_id' AND " .
383 "activity = 1 ORDER BY fee DESC, id ASC LIMIT 1");
384 $billdate = substr(($tmp['bill_date'] . "Not Billed"), 0, 10);
387 echo $arrow['doctor'];
394 <?php
xl('Invoice:','e')?
>
398 if ($INTEGRATED_AR) {
399 echo "$patient_id.$encounter_id";
402 echo $arrow['invnumber'];
410 <?php
xl('Svc Date:','e'); ?
>
418 <?php
xl('Done with:','e',''," ")?
>;
420 // Write a checkbox for each insurance. It is to be checked when
421 // we no longer expect any payments from that company for the claim.
422 if ($INTEGRATED_AR) {
423 $last_level_closed = 0 +
$ferow['last_level_closed'];
424 foreach (array(0 => 'None', 1 => 'Ins1', 2 => 'Ins2', 3 => 'Ins3') as $key => $value) {
425 if ($key && !arGetPayerID($patient_id, $svcdate, $key)) continue;
426 $checked = ($last_level_closed == $key) ?
" checked" : "";
427 echo " <input type='radio' name='form_done' value='$key'$checked />$value \n";
431 // The information is stored in the 'shipvia' field of the invoice.
432 $insgot = strtolower($arrow['notes']);
433 $insdone = strtolower($arrow['shipvia']);
434 foreach (array('Ins1', 'Ins2', 'Ins3') as $value) {
435 $lcvalue = strtolower($value);
436 $checked = (strpos($insdone, $lcvalue) === false) ?
"" : " checked";
437 if (strpos($insgot, $lcvalue) !== false) {
438 echo " <input type='checkbox' name='form_done_$value' value='1'$checked />$value \n";
445 if ($INTEGRATED_AR) {
447 echo xl('Check/EOB No.:');
450 echo "<input type='text' name='form_reference' size='10' value='' />\n";
458 <?php
xl('Last Bill Date:','e') ?
>
462 if ($INTEGRATED_AR) {
466 echo $arrow['transdate'];
471 <?php
xl('Now posting for:','e',''," ")?
>;
474 // TBD: check the first not-done-with insurance, not always Ins1!
476 <input type
='radio' name
='form_insurance' value
='Ins1' onclick
='setins("Ins1")' checked
/><?php
xl('Ins1','e')?
> 
;
477 <input type
='radio' name
='form_insurance' value
='Ins2' onclick
='setins("Ins2")' /><?php
xl('Ins2','e')?
> 
;
478 <input type
='radio' name
='form_insurance' value
='Ins3' onclick
='setins("Ins3")' /><?php
xl('Ins3','e')?
> 
;
479 <input type
='radio' name
='form_insurance' value
='Pt' onclick
='setins("Pt")' /><?php
xl('Patient','e')?
>
482 // TBD: I think the following is unused and can be removed.
484 <input type
='hidden' name
='form_eobs' value
='<?php echo addslashes($arrow['shipvia
']) ?>' />
488 if ($INTEGRATED_AR) {
490 echo xl('Check/EOB Date:');
493 echo "<input type='text' name='form_check_date' size='10' value='' />\n";
501 if (!$INTEGRATED_AR) xl('Due Date:','e');
506 <?php
if (!$INTEGRATED_AR) { ?
>
507 <input type
='text' name
='form_duedate' size
='10' value
='<?php echo $arrow['duedate
'] ?>'
508 title
='<?php xl('Due date mm
/dd
/yyyy
or yyyy
-mm
-dd
','e
')?>'>
512 <input type
="checkbox" name
="form_secondary" value
="1"> <?php
xl('Needs secondary billing','e')?
>
514 <input type
='submit' name
='form_save' value
='<?php xl('Save
','e
')?>'>
516 <input type
='button' value
='<?php xl('Cancel
','e
')?>' onclick
='window.close()'>
519 if ($INTEGRATED_AR) {
521 echo xl('Deposit Date:');
524 echo "<input type='text' name='form_deposit_date' size='10' value='' />\n";
525 echo "<input type='hidden' name='form_payer_id' value='' />\n";
526 echo "<input type='hidden' name='form_orig_reference' value='' />\n";
527 echo "<input type='hidden' name='form_orig_check_date' value='' />\n";
528 echo "<input type='hidden' name='form_orig_deposit_date' value='' />\n";
529 echo "<input type='hidden' name='form_pay_total' value='' />\n";
534 <?php
if ($pdrow['genericname2'] == 'Billing') { ?
>
537 <?php
xl('Billing Note:','e')?
>
539 <td colspan
='3' style
='color:red'>
540 <?php
echo $pdrow['genericval2'] ?
>
550 <table border
='0' cellpadding
='2' cellspacing
='0' width
='98%'>
552 <tr bgcolor
="#cccccc">
554 <?php
xl('Code','e')?
>
556 <td
class="dehead" align
="right">
557 <?php
xl('Charge','e')?
>
559 <td
class="dehead" align
="right">
560 <?php
xl('Balance','e')?
> 
;
563 <?php
xl('By/Source','e')?
>
566 <?php
xl('Date','e')?
>
569 <?php
xl('Pay','e')?
>
572 <?php
xl('Adjust','e')?
>
575 <?php
xl('Reason','e')?
>
580 foreach ($codes as $code => $cdata) {
582 $bgcolor = "#" . (($encount & 1) ?
"ddddff" : "ffdddd");
584 // this sorts the details more or less chronologically:
585 ksort($cdata['dtl']);
586 foreach ($cdata['dtl'] as $dkey => $ddata) {
587 $ddate = substr($dkey, 0, 10);
588 if (preg_match('/^(\d\d\d\d)(\d\d)(\d\d)\s*$/', $ddate, $matches)) {
589 $ddate = $matches[1] . '-' . $matches[2] . '-' . $matches[3];
593 /*****************************************************************
594 if ($ddata['chg'] > 0)
595 $tmpchg = $ddata['chg'];
596 else if ($ddata['chg'] < 0)
597 $tmpadj = 0 - $ddata['chg'];
598 *****************************************************************/
599 if ($ddata['chg'] != 0) {
600 if (isset($ddata['rsn'])) $tmpadj = 0 - $ddata['chg'];
601 else $tmpchg = $ddata['chg'];
604 <tr bgcolor
='<?php echo $bgcolor ?>'>
606 <?php
echo $dispcode; $dispcode = "" ?
>
608 <td
class="detail" align
="right">
609 <?php
bucks($tmpchg) ?
>
611 <td
class="detail" align
="right">
616 if (isset($ddata['plv'])) {
617 if (!$ddata['plv']) echo 'Pt/';
618 else echo 'Ins' . $ddata['plv'] . '/';
627 <?php
bucks($ddata['pmt']) ?
>
630 <?php
bucks($tmpadj) ?
>
633 <?php
echo $ddata['rsn'] ?
>
637 } // end of prior detail line
639 <tr bgcolor
='<?php echo $bgcolor ?>'>
641 <?php
echo $dispcode; $dispcode = "" ?
>
643 <td
class="detail" align
="right">
646 <td
class="detail" align
="right">
647 <input type
="hidden" name
="form_line[<?php echo $code ?>][bal]" value
="<?php bucks($cdata['bal']) ?>">
648 <input type
="hidden" name
="form_line[<?php echo $code ?>][ins]" value
="<?php echo $cdata['ins'] ?>">
649 <?php
printf("%.2f", $cdata['bal']) ?
> 
;
653 <?php
if (!$INTEGRATED_AR) { ?
>
654 <input type
="text" name
="form_line[<?php echo $code ?>][src]" size
="10"
655 style
="background-color:<?php echo $bgcolor ?>" />
656 <!-- title
="NM=notmet, CI=coins, CP=copay, NE=notelig, IT=insterm, PF=ptfull, PP=ptpart" -->
662 <?php
if (!$INTEGRATED_AR) { ?
>
663 <input type
="text" name
="form_line[<?php echo $code ?>][date]" size
="10"
664 style
="background-color:<?php echo $bgcolor ?>" />
669 <input type
="text" name
="form_line[<?php echo $code ?>][pay]" size
="10"
670 style
="background-color:<?php echo $bgcolor ?>" />
673 <input type
="text" name
="form_line[<?php echo $code ?>][adj]" size
="10"
674 style
="background-color:<?php echo $bgcolor ?>" />
675  
; <a href
="" onclick
="return writeoff('<?php echo $code ?>')">W
</a
>
678 <select name
="form_line[<?php echo $code ?>][reason]"
679 style
="background-color:<?php echo $bgcolor ?>">
681 // Adjustment reasons are now taken from the list_options table.
682 echo " <option value=''></option>\n";
683 $ores = sqlStatement("SELECT option_id, title FROM list_options " .
684 "WHERE list_id = 'adjreason' ORDER BY seq, title");
685 while ($orow = sqlFetchArray($ores)) {
686 echo " <option value='" . addslashes($orow['option_id']) . "'";
687 echo ">" . $orow['title'] . "</option>\n";
692 // TBD: Maybe a comment field would be good here, for appending
699 if (!$INTEGRATED_AR) SLClose();
705 <script language
="JavaScript">
706 var f1
= opener
.document
.forms
[0];
707 var f2
= document
.forms
[0];
708 if (f1
.form_source
) {
710 if ($INTEGRATED_AR) {
711 // These support creation and lookup of ar_session table entries:
712 echo " f2.form_reference.value = f1.form_source.value;\n";
713 echo " f2.form_check_date.value = f1.form_paydate.value;\n";
714 echo " f2.form_deposit_date.value = f1.form_deposit_date.value;\n";
715 echo " f2.form_payer_id.value = f1.form_payer_id.value;\n";
716 echo " f2.form_pay_total.value = f1.form_amount.value;\n";
717 echo " f2.form_orig_reference.value = f1.form_source.value;\n";
718 echo " f2.form_orig_check_date.value = f1.form_paydate.value;\n";
719 echo " f2.form_orig_deposit_date.value = f1.form_deposit_date.value;\n";
721 // While I'm thinking about it, some notes about eob sessions.
722 // If they do not have all of the session key fields in the search
723 // page, then show a warning at the top of the invoice page.
724 // Also when they go to save the invoice page and a session key
725 // field has changed, alert them to that and allow a cancel.
727 // Another point... when posting EOBs, the incoming payer ID might
728 // not match the payer ID for the patient's insurance. This is
729 // because the same payer might be entered more than once into the
730 // insurance_companies table. I don't think it matters much.
733 foreach ($codes as $code => $cdata) {
734 echo " f2['form_line[$code][src]'].value = f1.form_source.value;\n";
735 echo " f2['form_line[$code][date]'].value = f1.form_paydate.value;\n";