2 // Copyright (C) 2006-2010 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 module was written for one of my clients to report on cash
10 // receipts by practitioner. It is not as complete as it should be
11 // but I wanted to make the code available to the project because
12 // many other practices have this same need. - rod@sunsetsystems.com
14 require_once("../globals.php");
15 require_once("$srcdir/patient.inc");
16 require_once("$srcdir/sql-ledger.inc");
17 require_once("$srcdir/acl.inc");
18 require_once("$srcdir/formatting.inc.php");
19 require_once "$srcdir/options.inc.php";
20 require_once "$srcdir/formdata.inc.php";
21 require_once("../../custom/code_types.inc.php");
23 // This determines if a particular procedure code corresponds to receipts
24 // for the "Clinic" column as opposed to receipts for the practitioner. Each
25 // practice will have its own policies in this regard, so you'll probably
26 // have to customize this function. If you use the "fee sheet" encounter
27 // form then the code below may work for you.
29 include_once("../forms/fee_sheet/codes.php");
30 function is_clinic($code) {
32 $i = strpos($code, ':');
33 if ($i) $code = substr($code, 0, $i);
34 return ($bcodes['CPT4'][xl('Lab')][$code] ||
35 $bcodes['CPT4'][xl('Immunizations')][$code] ||
36 $bcodes['HCPCS'][xl('Therapeutic Injections')][$code]);
39 function bucks($amount) {
40 if ($amount) echo oeFormatMoney($amount);
43 if (! acl_check('acct', 'rep')) die(xl("Unauthorized access."));
45 $INTEGRATED_AR = $GLOBALS['oer_config']['ws_accounting']['enabled'] === 2;
47 if (!$INTEGRATED_AR) {
49 $chart_id_cash = SLQueryValue("select id from chart where accno = '$sl_cash_acc'");
50 if ($sl_err) die($sl_err);
53 $form_use_edate = $_POST['form_use_edate'];
55 $form_proc_codefull = trim($_POST['form_proc_codefull']);
56 // Parse the code type and the code from <code_type>:<code>
57 $tmp_code_array = explode(':',$form_proc_codefull);
58 $form_proc_codetype = $tmp_code_array[0];
59 $form_proc_code = $tmp_code_array[1];
61 $form_dx_codefull = trim($_POST['form_dx_codefull']);
62 // Parse the code type and the code from <code_type>:<code>
63 $tmp_code_array = explode(':',$form_dx_codefull);
64 $form_dx_codetype = $tmp_code_array[0];
65 $form_dx_code = $tmp_code_array[1];
67 $form_procedures = empty($_POST['form_procedures']) ?
0 : 1;
68 $form_from_date = fixDate($_POST['form_from_date'], date('Y-m-01'));
69 $form_to_date = fixDate($_POST['form_to_date'], date('Y-m-d'));
70 $form_facility = $_POST['form_facility'];
74 <?php
if (function_exists('html_header_show')) html_header_show(); ?
>
75 <style type
="text/css">
76 /* specifically include & exclude from printing */
82 #report_parameters_daterange {
91 /* specifically exclude some from the screen */
93 #report_parameters_daterange {
100 <script type
="text/javascript" src
="../../library/dialog.js"></script
>
101 <script language
="JavaScript">
102 // This is for callback by the find-code popup.
103 // Erases the current entry
104 // The target element is set by the find-code popup
105 // (this allows use of this in multiple form elements on the same page)
106 function set_related_target(codetype
, code
, selector
, codedesc
, target_element
) {
107 var f
= document
.forms
[0];
108 var s
= f
[target_element
].value
;
110 s
= codetype +
':' + code
;
114 f
[target_element
].value
= s
;
117 // This invokes the find-code (procedure/service codes) popup.
118 function sel_procedure() {
119 dlgopen('../patient_file/encounter/find_code_popup.php?target_element=form_proc_codefull&codetype=<?php echo attr(collect_codetypes("procedure","csv")) ?>', '_blank', 500, 400);
122 // This invokes the find-code (diagnosis codes) popup.
123 function sel_diagnosis() {
124 dlgopen('../patient_file/encounter/find_code_popup.php?target_element=form_dx_codefull&codetype=<?php echo attr(collect_codetypes("diagnosis","csv")) ?>', '_blank', 500, 400);
129 <title
><?
xl('Cash Receipts by Provider','e')?
></title
>
132 <body
class="body_top">
134 <span
class='title'><?php
xl('Report','e'); ?
> - <?php
xl('Cash Receipts by Provider','e'); ?
></span
>
136 <form method
='post' action
='sl_receipts_report.php' id
='theform'>
138 <div id
="report_parameters">
140 <input type
='hidden' name
='form_refresh' id
='form_refresh' value
=''/>
145 <div style
='float:left'>
150 <?php
xl('Facility','e'); ?
>:
153 <?php
dropdown_facility(strip_escape_custom($form_facility), 'form_facility'); ?
>
156 <?php
xl('Provider','e'); ?
>:
160 if (acl_check('acct', 'rep_a')) {
161 // Build a drop-down list of providers.
163 $query = "select id, lname, fname from users where " .
164 "authorized = 1 order by lname, fname";
165 $res = sqlStatement($query);
166 echo " <select name='form_doctor'>\n";
167 echo " <option value=''>-- " . xl('All Providers', 'e') . " --\n";
168 while ($row = sqlFetchArray($res)) {
169 $provid = $row['id'];
170 echo " <option value='$provid'";
171 if ($provid == $_POST['form_doctor']) echo " selected";
172 echo ">" . $row['lname'] . ", " . $row['fname'] . "\n";
176 echo "<input type='hidden' name='form_doctor' value='" . $_SESSION['authUserID'] . "'>";
181 <select name
='form_use_edate'>
182 <option value
='0'><?php
xl('Payment Date','e'); ?
></option
>
183 <option value
='1'<?php
if ($form_use_edate) echo ' selected' ?
>><?php
xl('Invoice Date','e'); ?
></option
>
189 <?php
xl('From','e'); ?
>:
192 <input type
='text' name
='form_from_date' id
="form_from_date" size
='10' value
='<?php echo $form_from_date; ?>'
193 title
='Date of appointments mm/dd/yyyy' >
194 <img src
='../pic/show_calendar.gif' align
='absbottom' width
='24' height
='22'
195 id
='img_from_date' border
='0' alt
='[?]' style
='cursor:pointer'
196 title
='<?php xl('Click here to choose a date
','e
'); ?>'>
199 <?php
xl('To','e'); ?
>:
202 <input type
='text' name
='form_to_date' id
="form_to_date" size
='10' value
='<?php echo $form_to_date; ?>'
203 title
='Optional end date mm/dd/yyyy' >
204 <img src
='../pic/show_calendar.gif' align
='absbottom' width
='24' height
='22'
205 id
='img_to_date' border
='0' alt
='[?]' style
='cursor:pointer'
206 title
='<?php xl('Click here to choose a date
','e
'); ?>'>
212 <?php
if (!$GLOBALS['simplified_demographics']) echo ' ' . xl('Procedure/Service', 'e') . ':'; ?
>
215 <input type
='text' name
='form_proc_codefull' size
='11' value
='<?php echo $form_proc_codefull; ?>' onclick
='sel_procedure()'
216 title
='<?php xl('Optional procedure
/service code
','e
'); ?>'
217 <?php
if ($GLOBALS['simplified_demographics']) echo "style='display:none'"; ?
>>
221 <?php
if (!$GLOBALS['simplified_demographics']) echo ' ' . xl('Diagnosis', 'e') . ':'; ?
>
224 <input type
='text' name
='form_dx_codefull' size
='11' value
='<?php echo $form_dx_codefull; ?>' onclick
='sel_diagnosis()'
225 title
='<?php xl('Enter a diagnosis code to exclude all invoices not containing it
','e
'); ?>'
226 <?php
if ($GLOBALS['simplified_demographics']) echo "style='display:none'"; ?
>>
230 <input type
='checkbox' name
='form_details' value
='1'<?php
if ($_POST['form_details']) echo " checked"; ?
>><?
xl('Details','e')?
>
231 <input type
='checkbox' name
='form_procedures' value
='1'<?php
if ($form_procedures) echo " checked"; ?
>><?
xl('Procedures','e')?
>
239 <td align
='left' valign
='middle' height
="100%">
240 <table style
='border-left:1px solid; width:100%; height:100%' >
243 <div style
='margin-left:15px'>
244 <a href
='#' class='css_button' onclick
='$("#form_refresh").attr("value","true"); $("#theform").submit();'>
246 <?php
xl('Submit','e'); ?
>
250 <?php
if ($_POST['form_refresh']) { ?
>
251 <a href
='#' class='css_button' onclick
='window.print()'>
253 <?php
xl('Print','e'); ?
>
267 if ($_POST['form_refresh']) {
269 <div id
="report_results">
270 <table border
='0' cellpadding
='1' cellspacing
='2' width
='98%'>
273 <?php
xl('Practitioner','e') ?
>
276 <?php
xl('Date','e') ?
>
278 <?php
if ($form_procedures) { ?
>
280 <?php
xl('Invoice','e') ?
>
283 <?php
if ($form_proc_codefull) { ?
>
285 <?php
xl('InvAmt','e') ?
>
288 <?php
if ($form_proc_codefull) { ?
>
290 <?php
xl('Insurance','e') ?
>
293 <?php
if ($form_procedures) { ?
>
295 <?php
xl('Procedure','e') ?
>
298 <?php
xl('Prof.','e') ?
>
301 <?php
xl('Clinic','e') ?
>
305 <?php
xl('Received','e') ?
>
310 if ($_POST['form_refresh']) {
311 $form_doctor = $_POST['form_doctor'];
314 if ($INTEGRATED_AR) {
315 $ids_to_skip = array();
318 // Get copays. These will be ignored if a CPT code was specified.
320 if (!$form_proc_code ||
!$form_proc_codetype) {
321 /*************************************************************
322 $query = "SELECT b.fee, b.pid, b.encounter, b.code_type, b.code, b.modifier, " .
323 "fe.date, fe.id AS trans_id, u.id AS docid " .
324 "FROM billing AS b " .
325 "JOIN form_encounter AS fe ON fe.pid = b.pid AND fe.encounter = b.encounter " .
326 "JOIN forms AS f ON f.pid = b.pid AND f.encounter = b.encounter AND f.formdir = 'newpatient' " .
327 "LEFT OUTER JOIN users AS u ON u.username = f.user " .
328 "WHERE b.code_type = 'COPAY' AND b.activity = 1 AND " .
329 "fe.date >= '$form_from_date 00:00:00' AND fe.date <= '$form_to_date 23:59:59'";
330 // If a facility was specified.
331 if ($form_facility) {
332 $query .= " AND fe.facility_id = '$form_facility'";
334 // If a doctor was specified.
336 $query .= " AND u.id = '$form_doctor'";
338 *************************************************************/
339 $query = "SELECT b.fee, b.pid, b.encounter, b.code_type, b.code, b.modifier, " .
340 "fe.date, fe.id AS trans_id, fe.provider_id AS docid, fe.invoice_refno " .
341 "FROM billing AS b " .
342 "JOIN form_encounter AS fe ON fe.pid = b.pid AND fe.encounter = b.encounter " .
343 "WHERE b.code_type = 'COPAY' AND b.activity = 1 AND " .
344 "fe.date >= '$form_from_date 00:00:00' AND fe.date <= '$form_to_date 23:59:59'";
345 // If a facility was specified.
346 if ($form_facility) {
347 $query .= " AND fe.facility_id = '$form_facility'";
349 // If a doctor was specified.
351 $query .= " AND fe.provider_id = '$form_doctor'";
353 /************************************************************/
355 $res = sqlStatement($query);
356 while ($row = sqlFetchArray($res)) {
357 $trans_id = $row['trans_id'];
358 $thedate = substr($row['date'], 0, 10);
359 $patient_id = $row['pid'];
360 $encounter_id = $row['encounter'];
362 if (!empty($ids_to_skip[$trans_id])) continue;
364 // If a diagnosis code was given then skip any invoices without
366 if ($form_dx_code && $form_dx_codetype) {
367 $tmp = sqlQuery("SELECT count(*) AS count FROM billing WHERE " .
368 "pid = '$patient_id' AND encounter = '$encounter_id' AND " .
369 "code_type = '$form_dx_codetype' AND code LIKE '$form_dx_code' AND " .
371 if (empty($tmp['count'])) {
372 $ids_to_skip[$trans_id] = 1;
377 $key = sprintf("%08u%s%08u%08u%06u", $row['docid'], $thedate,
378 $patient_id, $encounter_id, ++
$irow);
379 $arows[$key] = array();
380 $arows[$key]['transdate'] = $thedate;
381 $arows[$key]['amount'] = $row['fee'];
382 $arows[$key]['docid'] = $row['docid'];
383 $arows[$key]['project_id'] = 0;
384 $arows[$key]['memo'] = '';
385 $arows[$key]['invnumber'] = "$patient_id.$encounter_id";
386 $arows[$key]['irnumber'] = $row['invoice_refno'];
388 } // end copays (not $form_proc_code)
390 // Get ar_activity (having payments), form_encounter, forms, users, optional ar_session
391 /***************************************************************
392 $query = "SELECT a.pid, a.encounter, a.post_time, a.code, a.modifier, a.pay_amount, " .
393 "fe.date, fe.id AS trans_id, u.id AS docid, s.deposit_date, s.payer_id " .
394 "FROM ar_activity AS a " .
395 "JOIN form_encounter AS fe ON fe.pid = a.pid AND fe.encounter = a.encounter " .
396 "JOIN forms AS f ON f.pid = a.pid AND f.encounter = a.encounter AND f.formdir = 'newpatient' " .
397 "LEFT OUTER JOIN users AS u ON u.username = f.user " .
398 "LEFT OUTER JOIN ar_session AS s ON s.session_id = a.session_id " .
399 "WHERE a.pay_amount != 0 AND ( " .
400 "a.post_time >= '$form_from_date 00:00:00' AND a.post_time <= '$form_to_date 23:59:59' " .
401 "OR fe.date >= '$form_from_date 00:00:00' AND fe.date <= '$form_to_date 23:59:59' " .
402 "OR s.deposit_date >= '$form_from_date' AND s.deposit_date <= '$form_to_date' )";
403 // If a procedure code was specified.
404 if ($form_proc_code) $query .= " AND a.code = '$form_proc_code'";
405 // If a facility was specified.
406 if ($form_facility) $query .= " AND fe.facility_id = '$form_facility'";
407 // If a doctor was specified.
408 if ($form_doctor) $query .= " AND u.id = '$form_doctor'";
409 ***************************************************************/
410 $query = "SELECT a.pid, a.encounter, a.post_time, a.code, a.modifier, a.pay_amount, " .
411 "fe.date, fe.id AS trans_id, fe.provider_id AS docid, fe.invoice_refno, s.deposit_date, s.payer_id, " .
413 "FROM ar_activity AS a " .
414 "JOIN form_encounter AS fe ON fe.pid = a.pid AND fe.encounter = a.encounter " .
415 "LEFT OUTER JOIN ar_session AS s ON s.session_id = a.session_id " .
416 "LEFT OUTER JOIN billing AS b ON b.pid = a.pid AND b.encounter = a.encounter AND " .
417 "b.code = a.code AND b.modifier = a.modifier AND b.activity = 1 AND " .
418 "b.code_type != 'COPAY' AND b.code_type != 'TAX' " .
419 "WHERE a.pay_amount != 0 AND ( " .
420 "a.post_time >= '$form_from_date 00:00:00' AND a.post_time <= '$form_to_date 23:59:59' " .
421 "OR fe.date >= '$form_from_date 00:00:00' AND fe.date <= '$form_to_date 23:59:59' " .
422 "OR s.deposit_date >= '$form_from_date' AND s.deposit_date <= '$form_to_date' )";
423 // If a procedure code was specified.
424 // Support code type if it is in the ar_activity table. Note it is not always included, so
425 // also support a blank code type in ar_activity table.
426 if ($form_proc_codetype && $form_proc_code) $query .= " AND (a.code_type = '$form_proc_codetype' OR a.code_type = '') AND a.code = '$form_proc_code'";
427 // If a facility was specified.
428 if ($form_facility) $query .= " AND fe.facility_id = '$form_facility'";
429 // If a doctor was specified.
431 $query .= " AND ( b.provider_id = '$form_doctor' OR " .
432 "( ( b.provider_id IS NULL OR b.provider_id = 0 ) AND " .
433 "fe.provider_id = '$form_doctor' ) )";
435 /**************************************************************/
437 $res = sqlStatement($query);
438 while ($row = sqlFetchArray($res)) {
439 $trans_id = $row['trans_id'];
440 $patient_id = $row['pid'];
441 $encounter_id = $row['encounter'];
443 if (!empty($ids_to_skip[$trans_id])) continue;
445 if ($form_use_edate) {
446 $thedate = substr($row['date'], 0, 10);
448 if (!empty($row['deposit_date']))
449 $thedate = $row['deposit_date'];
451 $thedate = substr($row['post_time'], 0, 10);
453 if (strcmp($thedate, $form_from_date) < 0 ||
strcmp($thedate, $form_to_date) > 0) continue;
455 // If a diagnosis code was given then skip any invoices without
457 if ($form_dx_code && $form_dx_codetype) {
458 $tmp = sqlQuery("SELECT count(*) AS count FROM billing WHERE " .
459 "pid = '$patient_id' AND encounter = '$encounter_id' AND " .
460 "code_type = '$form_dx_codetype' AND code LIKE '$form_dx_code' AND " .
462 if (empty($tmp['count'])) {
463 $ids_to_skip[$trans_id] = 1;
468 $docid = empty($row['encounter_id']) ?
$row['docid'] : $row['encounter_id'];
469 $key = sprintf("%08u%s%08u%08u%06u", $docid, $thedate,
470 $patient_id, $encounter_id, ++
$irow);
471 $arows[$key] = array();
472 $arows[$key]['transdate'] = $thedate;
473 $arows[$key]['amount'] = 0 - $row['pay_amount'];
474 $arows[$key]['docid'] = $docid;
475 $arows[$key]['project_id'] = empty($row['payer_id']) ?
0 : $row['payer_id'];
476 $arows[$key]['memo'] = $row['code'];
477 $arows[$key]['invnumber'] = "$patient_id.$encounter_id";
478 $arows[$key]['irnumber'] = $row['invoice_refno'];
480 } // end $INTEGRATED_AR
483 if ($form_proc_code) {
484 $query = "SELECT acc_trans.amount, acc_trans.transdate, " .
485 "acc_trans.memo, acc_trans.project_id, acc_trans.trans_id, " .
486 "ar.invnumber, ar.employee_id, invoice.sellprice, invoice.qty " .
487 "FROM acc_trans, ar, invoice WHERE " .
488 "acc_trans.chart_id = $chart_id_cash AND " .
489 "acc_trans.memo ILIKE '$form_proc_code' AND " .
490 "ar.id = acc_trans.trans_id AND " .
491 "invoice.trans_id = acc_trans.trans_id AND " .
492 "invoice.serialnumber ILIKE acc_trans.memo AND " .
493 "invoice.sellprice >= 0.00 AND " .
494 "( invoice.description ILIKE 'CPT%' OR invoice.description ILIKE 'Proc%' ) AND ";
497 $query = "select acc_trans.amount, acc_trans.transdate, " .
498 "acc_trans.memo, acc_trans.trans_id, " .
499 "ar.invnumber, ar.employee_id from acc_trans, ar where " .
500 "acc_trans.chart_id = $chart_id_cash and " .
501 "ar.id = acc_trans.trans_id and ";
504 if ($form_use_edate) {
505 $query .= "ar.transdate >= '$form_from_date' and " .
506 "ar.transdate <= '$form_to_date'";
508 $query .= "acc_trans.transdate >= '$form_from_date' and " .
509 "acc_trans.transdate <= '$form_to_date'";
512 $query .= " order by ar.invnumber";
514 // echo "<!-- $query -->\n"; // debugging
516 $t_res = SLQuery($query);
517 if ($sl_err) die($sl_err);
529 for ($irow = 0; $irow < SLRowCount($t_res); ++
$irow) {
530 $row = SLGetRow($t_res, $irow);
532 list($patient_id, $encounter_id) = explode(".", $row['invnumber']);
534 // Under some conditions we may skip invoices that matched the SQL query.
536 if ($row['trans_id'] == $last_trans_id) {
537 if ($skipping) continue;
538 // same invoice and not skipping, do nothing.
539 } else { // new invoice
541 // If a diagnosis code was given then skip any invoices without
544 if (!SLQueryValue("SELECT count(*) FROM invoice WHERE " .
545 "invoice.trans_id = '" . $row['trans_id'] . "' AND " .
546 "( invoice.description ILIKE 'ICD9:$form_dx_code %' OR " .
547 "invoice.serialnumber ILIKE 'ICD9:$form_dx_code' )"))
553 // If a facility was specified then skip invoices whose encounters
554 // do not indicate that facility.
555 if ($form_facility) {
556 $tmp = sqlQuery("SELECT count(*) AS count FROM form_encounter WHERE " .
557 "pid = '$patient_id' AND encounter = '$encounter_id' AND " .
558 "facility_id = '$form_facility'");
559 if (empty($tmp['count'])) {
564 // Find out who the practitioner is.
565 /***********************************************************
566 $tmp = sqlQuery("SELECT users.id, users.authorized FROM forms, users WHERE " .
567 "forms.pid = '$patient_id' AND forms.encounter = '$encounter_id' AND " .
568 "forms.formdir = 'newpatient' AND users.username = forms.user");
569 $main_docid = empty($tmp['id']) ? 0 : $tmp['id'];
570 if (empty($tmp['authorized'])) {
571 $tmp = sqlQuery("SELECT users.id FROM billing, users WHERE " .
572 "billing.pid = '$patient_id' AND billing.encounter = '$encounter_id' AND " .
573 "billing.activity = 1 AND billing.fee > 0 AND " .
574 "users.id = billing.provider_id AND users.authorized = 1 " .
575 "ORDER BY billing.fee DESC, billing.id ASC LIMIT 1");
576 if (!empty($tmp['id'])) $main_docid = $tmp['id'];
578 ***********************************************************/
579 $tmp = sqlQuery("SELECT provider_id FROM form_encounter WHERE " .
580 "pid = '$patient_id' AND encounter = '$encounter_id' " .
581 "ORDER BY id DESC LIMIT 1");
582 $main_docid = $tmp['provider_id'] +
0;
584 // If a practitioner was specified then skip other practitioners.
586 if ($form_doctor != $main_docid) {
593 $row['docid'] = $main_docid;
594 $key = sprintf("%08u%s%08u%08u%06u", $main_docid, $row['transdate'],
595 $patient_id, $encounter_id, $irow);
599 } // end not $INTEGRATED_AR
604 foreach ($arows as $row) {
606 // Get insurance company name
608 if ($form_proc_codefull && $row['project_id']) {
609 $tmp = sqlQuery("SELECT name FROM insurance_companies WHERE " .
610 "id = '" . $row['project_id'] . "'");
611 $insconame = $tmp['name'];
616 if ($form_procedures && is_clinic($row['memo']))
617 $amount2 -= $row['amount'];
619 $amount1 -= $row['amount'];
621 // if ($docid != $row['employee_id']) {
622 if ($docid != $row['docid']) {
627 <tr bgcolor
="#ddddff">
628 <td
class="detail" colspan
="<?php echo ($form_proc_codefull ? 4 : 2) + ($form_procedures ? 2 : 0); ?>">
629 <?php
echo xl('Totals for ') . $docname ?
>
632 <?php
bucks($doctotal1) ?
>
634 <?php
if ($form_procedures) { ?
>
636 <?php
bucks($doctotal2) ?
>
645 $docid = $row['docid'];
646 $tmp = sqlQuery("SELECT lname, fname FROM users WHERE id = '$docid'");
647 $docname = empty($tmp) ?
'Unknown' : $tmp['fname'] . ' ' . $tmp['lname'];
649 $docnameleft = $docname;
652 if ($_POST['form_details']) {
657 <?php
echo $docnameleft; $docnameleft = " " ?
>
660 <?php
echo oeFormatShortDate($row['transdate']) ?
>
662 <?php
if ($form_procedures) { ?
>
664 <?php
echo empty($row['irnumber']) ?
$row['invnumber'] : $row['irnumber']; ?
>
668 if ($form_proc_code && $form_proc_codetype) {
669 echo " <td class='detail' align='right'>";
670 if ($INTEGRATED_AR) {
671 list($patient_id, $encounter_id) = explode(".", $row['invnumber']);
672 $tmp = sqlQuery("SELECT SUM(fee) AS sum FROM billing WHERE " .
673 "pid = '$patient_id' AND encounter = '$encounter_id' AND " .
674 "code_type = '$form_proc_codetype' AND code = '$form_proc_code' AND activity = 1");
678 bucks($row['sellprice'] * $row['qty']);
683 <?php
if ($form_proc_codefull) { ?
>
685 <?php
echo $insconame ?
>
688 <?php
if ($form_procedures) { ?
>
690 <?php
echo $row['memo'] ?
>
693 <td
class="detail" align
="right">
694 <?php
bucks($amount1) ?
>
696 <?php
if ($form_procedures) { ?
>
697 <td
class="detail" align
="right">
698 <?php
bucks($amount2) ?
>
704 $doctotal1 +
= $amount1;
705 $doctotal2 +
= $amount2;
706 $grandtotal1 +
= $amount1;
707 $grandtotal2 +
= $amount2;
711 <tr bgcolor
="#ddddff">
712 <td
class="detail" colspan
="<?php echo ($form_proc_codefull ? 4 : 2) + ($form_procedures ? 2 : 0); ?>">
713 <?php
echo xl('Totals for ') . $docname ?
>
716 <?php
bucks($doctotal1) ?
>
718 <?php
if ($form_procedures) { ?
>
720 <?php
bucks($doctotal2) ?
>
725 <tr bgcolor
="#ffdddd">
726 <td
class="detail" colspan
="<?php echo ($form_proc_codefull ? 4 : 2) + ($form_procedures ? 2 : 0); ?>">
727 <?php
xl('Grand Totals','e') ?
>
730 <?php
bucks($grandtotal1) ?
>
732 <?php
if ($form_procedures) { ?
>
734 <?php
bucks($grandtotal2) ?
>
741 if (!$INTEGRATED_AR) SLClose();
748 <?php
echo xl('Please input search criteria above, and click Submit to view results.', 'e' ); ?
>
755 <!-- stuff
for the popup calendar
-->
756 <link rel
='stylesheet' href
='<?php echo $css_header ?>' type
='text/css'>
757 <style type
="text/css">@import
url(../../library
/dynarch_calendar
.css
);</style
>
758 <script type
="text/javascript" src
="../../library/dynarch_calendar.js"></script
>
759 <?php
include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?
>
760 <script type
="text/javascript" src
="../../library/dynarch_calendar_setup.js"></script
>
761 <script type
="text/javascript" src
="../../library/js/jquery.1.3.2.js"></script
>
763 <script language
="Javascript">
764 Calendar
.setup({inputField
:"form_from_date", ifFormat
:"%Y-%m-%d", button
:"img_from_date"});
765 Calendar
.setup({inputField
:"form_to_date", ifFormat
:"%Y-%m-%d", button
:"img_to_date"});