3 * Fee Sheet Program used to create charges, copays and add diagnosis codes to the encounter
6 * @link http://www.open-emr.org
7 * @author Rod Roark <rod@sunsetsystems.com>
8 * @author Terry Hill <terry@lillysystems.com>
9 * @author Brady Miller <brady.g.miller@gmail.com>
10 * @copyright Copyright (c) 2005-2016 Rod Roark <rod@sunsetsystems.com>
11 * @copyright Copyright (c) 2018 Brady Miller <brady.g.miller@gmail.com>
12 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
14 use OpenEMR\Core\Header
;
16 require_once("../../globals.php");
17 require_once("$srcdir/FeeSheetHtml.class.php");
18 require_once("codes.php");
19 require_once("$srcdir/options.inc.php");
22 if (!acl_check_form('fee_sheet')) {
24 <script
>alert('<?php echo xls("Not authorized"); ?>')</script
>;
29 // Some table cells will not be displayed unless insurance billing is used.
30 $usbillstyle = $GLOBALS['ippf_specific'] ?
" style='display:none'" : "";
31 $justifystyle = justifiers_are_used() ?
"" : " style='display:none'";
33 $liprovstyle = (isset($GLOBALS['support_fee_sheet_line_item_provider']) &&
34 $GLOBALS['support_fee_sheet_line_item_provider'] != 1) ?
" style='display:none'" : "";
36 // This flag comes from the LBFmsivd form and perhaps later others.
37 $rapid_data_entry = empty($_GET['rde']) ?
0 : 1;
39 // This comes from the Add More Items button, or is preserved from its previous value.
40 $add_more_items = (empty($_GET['addmore']) && empty($_POST['bn_addmore'])) ?
0 : 1;
44 // Determine if more than one price level is in use.
45 $tmp = sqlQuery("SELECT COUNT(*) AS count FROM list_options where list_id = 'pricelevel' AND activity = 1");
46 $price_levels_are_used = $tmp['count'] > 1;
48 $institutional = $GLOBALS['ub04_support'] == "1" ?
true : false;
49 // Format a money amount with decimals but no other decoration.
50 // Second argument is used when extra precision is required.
51 function formatMoneyNumber($value, $extradecimals = 0)
53 return sprintf('%01.' . ($GLOBALS['currency_decimals'] +
$extradecimals) . 'f', $value);
56 // Helper function for creating drop-lists.
57 function endFSCategory()
59 global $i, $last_category, $FEE_SHEET_COLUMNS;
60 if (! $last_category) {
66 if ($i >= $FEE_SHEET_COLUMNS) {
72 // Generate JavaScript to build the array of diagnoses.
73 function genDiagJS($code_type, $code)
76 if ($code_types[$code_type]['diag']) {
77 echo "diags.push('" . attr($code_type) . "|" . attr($code) . "');\n";
81 // Write all service lines to the web form.
83 function echoServiceLines()
85 global $code_types, $justinit, $usbillstyle, $liprovstyle, $justifystyle, $fs, $price_levels_are_used, $institutional;
87 foreach ($fs->serviceitems
as $lino => $li) {
88 $id = $li['hidden']['id'];
89 $codetype = $li['hidden']['code_type'];
90 $code = $li['hidden']['code'];
92 $revenue_code = $li['hidden']['revenue_code'];
94 $modifier = $li['hidden']['mod'];
95 $billed = $li['hidden']['billed'];
96 $ndc_info = isset($li['ndc_info']) ?
$li['ndc_info'] : '';
97 $pricelevel = $li['pricelevel'];
98 $justify = $li['justify'];
100 $strike1 = $li['del'] ?
"<strike>" : "";
101 $strike2 = $li['del'] ?
"</strike>" : "";
105 echo " <td class='billcell'>$strike1" .
106 ($codetype == 'COPAY' ?
xl($codetype) : text($codetype)) . $strike2;
107 // if the line to ouput is copay, show the date here passed as $ndc_info,
108 // since this variable is not applicable in the case of copay.
109 if ($codetype == 'COPAY') {
110 if (!empty($ndc_info)) {
111 echo "(" . text($ndc_info) . ")";
117 echo "<input type='hidden' name='bill[" . attr($lino) . "][id]' value='" . attr($id) . "' />";
120 echo "<input type='hidden' name='bill[" . attr($lino) . "][code_type]' value='" . attr($codetype) . "' />";
121 echo "<input type='hidden' name='bill[" . attr($lino) . "][code]' value='" . attr($code) . "' />";
122 echo "<input type='hidden' name='bill[" . attr($lino)."][billed]' value='" . attr($billed)."' />";
123 if (isset($li['hidden']['method'])) {
124 echo "<input type='hidden' name='bill[$lino][method]' value='" . attr($li['hidden']['method' ]) . "' />";
125 echo "<input type='hidden' name='bill[$lino][cyp]' value='" . attr($li['hidden']['cyp' ]) . "' />";
126 echo "<input type='hidden' name='bill[$lino][methtype]' value='" . attr($li['hidden']['methtype']) . "' />";
131 if ($codetype != 'COPAY') {
132 echo " <td class='billcell'>$strike1" . text($code) . "$strike2</td>\n";
134 echo " <td class='billcell'> </td>\n";
137 echo " <td class='billcell'>$strike1" . text($li['code_text']) . "$strike2</td>\n";
140 if ($institutional) {
141 echo " <td class='billcell'>$strike1" . text($revenue_code) . "$strike2" .
142 "<input type='hidden' name='bill[" . attr($lino) . "][revenue_code]' value='" . attr($revenue_code) . "'></td>\n";
145 if (modifiers_are_used(true)) {
146 echo " <td class='billcell'>$strike1" . text($modifier) . "$strike2" .
147 "<input type='hidden' name='bill[" . attr($lino) . "][mod]' value='" . attr($modifier) . "'></td>\n";
150 if (fees_are_used()) {
151 if ($price_levels_are_used) {
152 // Show price level for this line.
153 echo " <td class='billcell' align='center'>";
154 echo $fs->genPriceLevelSelect('', ' ', $li['hidden']['codes_id'], '', $pricelevel, true);
158 echo " <td class='billcell' align='right'>" . text(oeFormatMoney($li['price'])) . "</td>\n";
159 if ($codetype != 'COPAY') {
160 echo " <td class='billcell' align='center'>" . text($li['units']) . "</td>\n";
162 echo " <td class='billcell'> </td>\n";
165 echo " <td class='billcell' align='center'$justifystyle>$justify</td>\n";
168 // Show provider for this line.
169 echo " <td class='billcell' align='center' $liprovstyle>";
170 echo $fs->genProviderSelect('', '-- ' .xl("Default"). ' --', $li['provid'], true);
173 if ($code_types[$codetype]['claim'] && !$code_types[$codetype]['diag']) {
174 echo " <td class='billcell' align='center'$usbillstyle>" .
175 text($li['notecodes']) . "</td>\n";
177 echo " <td class='billcell' align='center'$usbillstyle></td>\n";
180 echo " <td class='billcell' align='center'$usbillstyle><input type='checkbox'" .
181 ($li['auth'] ?
" checked" : "") . " disabled /></td>\n";
183 if ($GLOBALS['gbl_auto_create_rx']) {
184 echo " <td class='billcell' align='center'> </td>\n";
187 echo " <td class='billcell' align='center'><input type='checkbox'" .
188 " disabled /></td>\n";
189 } else { // not billed
190 if ($institutional) {
191 if ($codetype != 'COPAY' && $codetype != 'ICD10') {
192 echo " <td class='billcell'><input type='text' class='revcode' name='bill[" . attr($lino) . "][revenue_code]' " .
193 "title='" . xla("Revenue Code for this item. Type for hints/search") . "' " .
194 "value='" . attr($revenue_code) . "' size='4'></td>\n";
196 echo " <td class='billcell'> </td>\n";
199 if (modifiers_are_used(true)) {
200 if ($codetype != 'COPAY' && ($code_types[$codetype]['mod'] ||
$modifier)) {
201 echo " <td class='billcell'><input type='text' name='bill[" . attr($lino) . "][mod]' " .
202 "title='" . xla("Multiple modifiers can be separated by colons or spaces, maximum of 4 (M1:M2:M3:M4)") . "' " .
203 "value='" . attr($modifier) . "' size='" . attr($code_types[$codetype]['mod']) . "'></td>\n";
205 echo " <td class='billcell'> </td>\n";
209 if (fees_are_used()) {
210 if ($codetype == 'COPAY' ||
$code_types[$codetype]['fee'] ||
$fee != 0) {
211 if ($price_levels_are_used) {
212 echo " <td class='billcell' align='center'>";
213 echo $fs->genPriceLevelSelect("bill[$lino][pricelevel]", ' ', $li['hidden']['codes_id'], '', $pricelevel);
217 echo " <td class='billcell' align='right'>" .
218 "<input type='text' name='bill[$lino][price]' " .
219 "value='" . attr($li['price']) . "' size='6' onchange='setSaveAndClose()'";
220 if (acl_check('acct', 'disc')) {
221 echo " style='text-align:right'";
223 echo " style='text-align:right;background-color:transparent' readonly";
228 echo " <td class='billcell' align='center'>";
229 if ($codetype != 'COPAY') {
230 echo "<input type='text' name='bill[" . attr($lino) . "][units]' " .
231 "value='" . attr($li['units']) . "' size='2' style='text-align:right'>";
233 echo "<input type='hidden' name='bill[" . attr($lino) . "][units]' value='" . attr($li['units']) . "'>";
238 if ($code_types[$codetype]['just'] ||
$li['justify']) {
239 echo " <td class='billcell' align='center'$justifystyle>";
240 echo "<select name='bill[" . attr($lino) . "][justify]' onchange='setJustify(this)'>";
241 echo "<option value='" . attr($li['justify']) . "'>" . text($li['justify']) . "</option></select>";
243 $justinit .= "setJustify(f['bill[" . attr($lino) . "][justify]']);\n";
245 echo " <td class='billcell'$justifystyle> </td>\n";
248 if ($price_levels_are_used) {
249 echo " <td class='billcell'> </td>\n";
252 echo " <td class='billcell'> </td>\n";
253 echo " <td class='billcell'> </td>\n";
254 echo " <td class='billcell'$justifystyle> </td>\n"; // justify
258 // Provider drop-list for this line.
259 echo " <td class='billcell' align='center' $liprovstyle>";
260 echo $fs->genProviderSelect("bill[$lino][provid]", '-- '.xl("Default").' --', $li['provid']);
263 if ($code_types[$codetype]['claim'] && !$code_types[$codetype]['diag']) {
264 echo " <td class='billcell' align='center'$usbillstyle><input type='text' name='bill[" . attr($lino) . "][notecodes]' " .
265 "value='" . text($li['notecodes']) . "' maxlength='10' size='8' /></td>\n";
267 echo " <td class='billcell' align='center'$usbillstyle></td>\n";
270 echo " <td class='billcell' align='center'$usbillstyle><input type='checkbox' name='bill[".attr($lino) . "][auth]' " .
271 "value='1'" . ($li['auth'] ?
" checked" : "") . " /></td>\n";
273 if ($GLOBALS['gbl_auto_create_rx']) {
274 echo " <td class='billcell' align='center'> </td>\n"; // KHY: May need to confirm proper location of this cell
277 echo " <td class='billcell' align='center'><input type='checkbox' name='bill[" . attr($lino) . "][del]' " .
278 "value='1'" . ($li['del'] ?
" checked" : "") . " /></td>\n";
283 // If NDC info exists or may be required, add a line for it.
284 if (isset($li['ndcnum'])) {
286 echo " <td class='billcell' colspan='2'> </td>\n";
287 echo " <td class='billcell' colspan='6'> NDC: ";
288 echo "<input type='text' name='bill[" . attr($lino) . "][ndcnum]' value='" . attr($li['ndcnum']) . "' " .
289 "size='11' style='background-color:transparent'>";
290 echo " Qty: ";
291 echo "<input type='text' name='bill[" . attr($lino) . "][ndcqty]' value='" . attr($li['ndcqty']) . "' " .
292 "size='3' style='background-color:transparent;text-align:right'>";
294 echo "<select name='bill[" . attr($lino) . "][ndcuom]' style='background-color:transparent'>";
295 foreach ($fs->ndc_uom_choices
as $key => $value) {
296 echo "<option value='" . attr($key) . "'";
297 if ($key == $li['ndcuom']) {
301 echo ">" . text($value) . "</option>";
307 } elseif (!empty($li['ndc_info'])) {
309 echo " <td class='billcell' colspan='2'> </td>\n";
310 echo " <td class='billcell' colspan='6'> " . xlt("NDC Data") . ": " . text($li['ndc_info']) . "</td>\n";
316 // Write all product lines to the web form.
318 function echoProductLines()
320 global $code_types, $usbillstyle, $liprovstyle, $justifystyle, $fs, $price_levels_are_used;
322 foreach ($fs->productitems
as $lino => $li) {
323 $drug_id = $li['hidden']['drug_id'];
324 $selector = $li['hidden']['selector'];
325 $sale_id = $li['hidden']['sale_id'];
326 $billed = $li['hidden']['billed'];
328 $price = $li['price'];
329 $pricelevel = $li['pricelevel'];
330 $units = $li['units'];
332 $warehouse_id = $li['warehouse'];
335 $strike1 = ($sale_id && $del) ?
"<strike>" : "";
336 $strike2 = ($sale_id && $del) ?
"</strike>" : "";
339 echo " <td class='billcell'>{$strike1}" . xlt("Product") . "$strike2";
340 echo "<input type='hidden' name='prod[" . attr($lino) . "][sale_id]' value='" . attr($sale_id) . "'>";
341 echo "<input type='hidden' name='prod[" . attr($lino) . "][drug_id]' value='" . attr($drug_id) . "'>";
342 echo "<input type='hidden' name='prod[" . attr($lino) . "][selector]' value='" . attr($selector) . "'>";
343 echo "<input type='hidden' name='prod[" . attr($lino) . "][billed]' value='" . attr($billed) . "'>";
344 if (isset($li['hidden']['method'])) {
345 echo "<input type='hidden' name='prod[$lino][method]' value='" . attr($li['hidden']['method' ]) . "' />";
346 echo "<input type='hidden' name='prod[$lino][methtype]' value='" . attr($li['hidden']['methtype']) . "' />";
351 echo " <td class='billcell'>$strike1" . text($drug_id) . "$strike2</td>\n";
353 echo " <td class='billcell'>$strike1" . text($li['code_text']) . "$strike2</td>\n";
355 if (modifiers_are_used(true)) {
356 echo " <td class='billcell'> </td>\n";
360 if (fees_are_used()) {
361 if ($price_levels_are_used) {
362 echo " <td class='billcell' align='center'>";
363 echo $fs->genPriceLevelSelect('', ' ', $drug_id, $selector, $pricelevel, true);
367 echo " <td class='billcell' align='right'>" . text(oeFormatMoney($price)) . "</td>\n";
368 echo " <td class='billcell' align='center'>" . text($units) . "</td>\n";
371 if (justifiers_are_used()) { // KHY Evaluate proper position/usage of if justifiers
372 echo " <td class='billcell' align='center'$justifystyle> </td>\n"; // justify
375 // Show warehouse for this line.
376 echo " <td class='billcell' align='center' $liprovstyle>";
377 echo $fs->genWarehouseSelect('', ' ', $warehouse_id, true, $drug_id, $sale_id > 0);
380 echo " <td class='billcell' align='center'$usbillstyle> </td>\n"; // note codes
381 echo " <td class='billcell' align='center'$usbillstyle> </td>\n"; // auth
382 if ($GLOBALS['gbl_auto_create_rx']) {
383 echo " <td class='billcell' align='center'><input type='checkbox'" . // rx
384 " disabled /></td>\n";
387 echo " <td class='billcell' align='center'><input type='checkbox'" . // del
388 " disabled /></td>\n";
389 } else { // not billed
390 if (fees_are_used()) {
391 if ($price_levels_are_used) {
392 echo " <td class='billcell' align='center'>";
393 echo $fs->genPriceLevelSelect("prod[$lino][pricelevel]", ' ', $drug_id, $selector, $pricelevel);
397 echo " <td class='billcell' align='right'>" .
398 "<input type='text' name='prod[" . attr($lino) . "][price]' " .
399 "value='" . attr($price) . "' size='6' onchange='setSaveAndClose()'";
400 if (acl_check('acct', 'disc')) {
401 echo " style='text-align:right'";
403 echo " style='text-align:right;background-color:transparent' readonly";
407 echo " <td class='billcell' align='center'>";
408 echo "<input type='text' name='prod[" . attr($lino) . "][units]' " .
409 "value='" . attr($units) . "' size='2' style='text-align:right'>";
413 if (justifiers_are_used()) {
414 echo " <td class='billcell'$justifystyle> </td>\n"; // justify
417 // Generate warehouse selector if there is a choice of warehouses.
418 echo " <td class='billcell' align='center' $liprovstyle>";
419 echo $fs->genWarehouseSelect("prod[$lino][warehouse]", ' ', $warehouse_id, false, $drug_id, $sale_id > 0);
422 echo " <td class='billcell' align='center'$usbillstyle> </td>\n"; // note codes
423 echo " <td class='billcell' align='center'$usbillstyle> </td>\n"; // auth
424 if ($GLOBALS['gbl_auto_create_rx']) {
425 echo " <td class='billcell' align='center'>" .
426 "<input type='checkbox' name='prod[$lino][rx]' value='1'" .
427 ($rx ?
" checked" : "") . " /></td>\n";
430 echo " <td class='billcell' align='center'><input type='checkbox' name='prod[" . attr($lino) . "][del]' " .
431 "value='1'" . ($del ?
" checked" : "") . " /></td>\n";
438 $fs = new FeeSheetHtml();
440 // $FEE_SHEET_COLUMNS should be defined in codes.php.
441 if (empty($FEE_SHEET_COLUMNS)) {
442 $FEE_SHEET_COLUMNS = 2;
445 // Update price level in patient demographics if it's changed.
446 if (!empty($_POST['pricelevel'])) {
447 $fs->updatePriceLevel($_POST['pricelevel']);
450 $current_checksum = $fs->visitChecksum();
451 // It's important to look for a checksum mismatch even if we're just refreshing
452 // the display, otherwise the error goes undetected on a refresh-then-save.
453 if (isset($_POST['form_checksum'])) {
454 if ($_POST['form_checksum'] != $current_checksum) {
455 $alertmsg = xl('Someone else has just changed this visit. Please cancel this page and try again.');
456 $comment = "CHECKSUM ERROR, expecting '{$_POST['form_checksum']}'";
457 newEvent("checksum", $_SESSION['authUser'], $_SESSION['authProvider'], 1, $comment, $pid);
461 if (!$alertmsg && ($_POST['bn_save'] ||
$_POST['bn_save_close'])) {
462 $alertmsg = $fs->checkInventory($_POST['prod']);
465 // If Save or Save-and-Close was clicked, save the new and modified billing
466 // lines; then if no error, redirect to $GLOBALS['form_exit_url'].
468 if (!$alertmsg && ($_POST['bn_save'] ||
$_POST['bn_save_close'] ||
$_POST['bn_save_stay'])) {
469 $main_provid = 0 +
$_POST['ProviderID'];
470 $main_supid = 0 +
(int)$_POST['SupervisorID'];
477 $_POST['default_warehouse'],
478 $_POST['bn_save_close']
481 if ($_POST['bn_save_stay']) {
482 $current_checksum = $fs->visitChecksum();
485 // Note: Taxes are computed at checkout time (in pos_checkout.php which
486 // also posts to SL). Currently taxes with insurance claims make no sense,
487 // so for now we'll ignore tax computation in the insurance billing logic.
489 if ($_POST['running_as_ajax']) {
490 // In the case of running as an AJAX handler, we need to return this same
491 // form with an updated checksum to properly support the invoking logic.
492 // See review/js/fee_sheet_core.js for that logic.
493 $current_checksum = $fs->visitChecksum(true);
494 // Also remove form data for the newly entered lines so they are not
495 // duplicated from the database.
496 unset($_POST['bill']);
497 unset($_POST['prod']);
498 } elseif (!isset($_POST['bn_save_stay'])) { // not running as ajax
499 // If appropriate, update the status of the related appointment to
501 updateAppointmentStatus($fs->pid
, $fs->visit_date
, '<');
503 // More Family Planning stuff.
504 if (isset($_POST['ippfconmeth'])) {
505 $tmp_form_id = $fs->doContraceptionForm($_POST['ippfconmeth'], $_POST['newmauser'], $main_provid);
507 // Contraceptive method does not match what is in an existing Contraception
508 // form for this visit, or there is no such form. Open the form.
509 formJump("{$GLOBALS['rootdir']}/patient_file/encounter/view_form.php" .
510 "?formname=LBFccicon&id=" . ($tmp_form_id < 0 ?
0 : $tmp_form_id));
516 if ($rapid_data_entry ||
($_POST['bn_save_close'] && $_POST['form_has_charges'])) {
517 // In rapid data entry mode or if "Save and Checkout" was clicked,
518 // we go directly to the Checkout page.
519 formJump("{$GLOBALS['rootdir']}/patient_file/pos_checkout.php?framed=1" .
520 "&ptid={$fs->pid}&enid={$fs->encounter}&rde=$rapid_data_entry");
522 // Otherwise return to the normal encounter summary frameset.
524 formHeader("Redirecting....");
530 } // end not running as ajax
531 } // end save or save-and-close
533 // Handle reopen request. In that case no other changes will be saved.
534 // If there was a checkout this will undo it.
535 if (!$alertmsg && $_POST['bn_reopen']) {
536 doVoid($fs->pid
, $fs->encounter
, true);
537 $current_checksum = $fs->visitChecksum();
538 // Remove the line items so they are refreshed from the database on redisplay.
539 unset($_POST['bill']);
540 unset($_POST['prod']);
543 $billresult = getBillingByEncounter($fs->pid
, $fs->encounter
, "*");
546 <?php Header
::setupHeader(['knockout', 'jquery-ui', 'jquery-ui-base']);?
>
548 /*.billcell { font-family: sans-serif; font-size: 10pt }*/
549 .ui
-autocomplete
{ max
-height
: 250px
; max
-width
: 350px
; overflow
-y
: auto
; overflow
-x
: hidden
; }
552 var mypcc
= '<?php echo $GLOBALS['phone_country_code
'] ?>';
553 var diags
= new Array();
557 foreach ($billresult as $iter) {
558 genDiagJS($iter["code_type"], trim($iter["code"]));
562 if ($_POST['bill']) {
563 foreach ($_POST['bill'] as $iter) {
565 continue; // skip if Delete was checked
569 continue; // skip if it came from the database
572 genDiagJS($iter["code_type"], $iter["code"]);
576 if ($_POST['newcodes']) {
577 $arrcodes = explode('~', $_POST['newcodes']);
578 foreach ($arrcodes as $codestring) {
579 if ($codestring === '') {
583 $arrcode = explode('|', $codestring);
584 list($code, $modifier) = explode(":", $arrcode[1]);
585 genDiagJS($arrcode[0], $code);
589 function reinitForm(){
591 $
( ".revcode" ).autocomplete({
593 source
: function( request
, response
) {
594 var term
= request
.term
;
595 request
.code_group
= "revenue_code";
596 if ( term in cache
) {
597 response( cache
[ term
] );
600 $
.getJSON( "<?php echo $GLOBALS['web_root'] ?>/interface/billing/ub04_helpers.php", request
, function( data
, status
, xhr
) {
601 cache
[ term
] = data
;
605 }).dblclick(function(event
) {
606 $
(this
).autocomplete('search'," ");
610 // This is invoked by <select onchange> for the various dropdowns,
611 // including search results.
612 function codeselect(selobj
) {
613 var i
= selobj ? selobj
.selectedIndex
: -1;
615 top
.restoreSession();
616 var f
= document
.forms
[0];
617 if (selobj
) f
.newcodes
.value
= selobj
.options
[i
].value
;
622 function copayselect() {
623 top
.restoreSession();
624 var f
= document
.forms
[0];
625 f
.newcodes
.value
= 'COPAY||';
629 <?php
echo $fs->jsLineItemValidation(); ?
>
631 function validate(f
) {
633 var reopening
= f
.bn_reopen
.clicked
;
634 var voiding
= reopening
&& f
.bn_reopen
.clicked
== 2;
635 f
.bn_reopen
.clicked
= false;
638 if (!confirm('<?php echo xls('Re
-opening this visit will cause a void
. Payment information will need to be re
-entered
. Do you want to proceed?
'); ?>')) {
642 top
.restoreSession();
646 var refreshing
= false;
648 refreshing
= f
.bn_refresh
.clicked ?
true : false;
649 f
.bn_refresh
.clicked
= false;
652 refreshing
= refreshing || f
.bn_addmore
.clicked
;
653 f
.bn_addmore
.clicked
= false;
655 var searching
= false;
657 searching
= f
.bn_search
.clicked ?
true : false;
658 f
.bn_search
.clicked
= false;
660 if (!refreshing
&& !searching
) {
661 if (!jsLineItemValidation(f
)) return false;
663 top
.restoreSession();
667 // When a justify selection is made, apply it to the current list for
668 // this procedure and then rebuild its selection list.
670 function setJustify(seljust
) {
671 var theopts
= seljust
.options
;
672 var jdisplay
= theopts
[0].text
;
673 // Compute revised justification string. Note this does nothing if
674 // the first entry is still selected, which is handy at startup.
675 if (seljust
.selectedIndex
> 0) {
676 var newdiag
= seljust
.value
;
677 if (newdiag
.length
== 0) {
681 if (jdisplay
.length
) jdisplay +
= ',';
685 // Rebuild selection list.
686 var jhaystack
= ',' + jdisplay +
',';
689 theopts
[j++
] = new Option(jdisplay
,jdisplay
,true,true);
690 for (var i
= 0; i
< diags
.length
; ++i
) {
691 if (jhaystack
.indexOf(',' + diags
[i
] +
',') < 0) {
692 theopts
[j++
] = new Option(diags
[i
],diags
[i
],false,false);
695 theopts
[j++
] = new Option('Clear','',false,false);
698 // Determine if there are any charges in this visit.
699 function hasCharges() {
700 var f
= document
.forms
[0];
701 for (var i
= 0; i
< f
.elements
.length
; ++i
) {
702 var elem
= f
.elements
[i
];
703 if (elem
.name
.indexOf('[price]') > 0) {
704 var fee
= Number(elem
.value
);
705 if (!isNaN(fee
) && fee
!= 0) return true;
711 // Function to check if there are any charges in the form, and to enable
712 // or disable the Save and Close button accordingly.
714 function setSaveAndClose() {
715 var f
= document
.forms
[0];
716 if (!f
.bn_save_close
) return;
718 f
.form_has_charges
.value
= '1';
719 f
.bn_save_close
.value
= '<?php echo xla('Save
and Checkout
'); ?>';
722 f
.form_has_charges
.value
= '0';
723 f
.bn_save_close
.value
= '<?php echo xla('Save
and Close
'); ?>';
727 // Open the add-event dialog.
729 var f
= document
.forms
[0];
730 var url
= '../../main/calendar/add_edit_event.php?patientid=<?php echo urlencode($fs->pid); ?>';
731 if (f
.ProviderID
&& f
.ProviderID
.value
) {
732 url +
= '&userid=' +
parseInt(f
.ProviderID
.value
);
734 dlgopen(url
, '_blank', 600, 300);
738 function warehouse_changed(sel
) {
739 if (!confirm('<?php echo xls('Do you really want to change Warehouse?
'); ?>')) {
740 // They clicked Cancel so reset selection to its default state.
741 for (var i
= 0; i
< sel
.options
.length
; ++i
) {
742 sel
.options
[i
].selected
= sel
.options
[i
].defaultSelected
;
747 // Invoked when a line item price level is changed.
748 function pricelevel_changed(sel
) {
749 var f
= document
.forms
[0];
750 var prname
= sel
.name
.replace('pricelevel', 'price');
752 var price
= parseFloat(sel
.options
[sel
.selectedIndex
].id
.substring(4));
753 if (isNaN(price
)) price
= 0;
754 f
[prname
].value
= price
;
757 alert('<?php echo xls('Form element not found
'); ?>: ' + prname
);
763 @media only screen
and (max
-width
: 1024px
) {
764 div
.category
-display
{
765 width
:100%
!Important
;
767 div
.category
-display
> button
{
768 width
:75%
!Important
;
774 "SELECT p.fname, p.mname, p.lname, fe.date FROM " .
775 "form_encounter AS fe, forms AS f, patient_data AS p WHERE " .
776 "p.pid = ? AND f.pid = p.pid AND f.encounter = ? AND " .
777 "f.formdir = 'newpatient' AND f.deleted = 0 AND " .
778 "fe.id = f.form_id LIMIT 1",
779 array($pid, $encounter)
781 $name = $enrow['fname'] . ' ';
782 $name .= (!empty($enrow['mname'])) ?
$enrow['mname'] . ' ' . $enrow['lname'] : $enrow['lname'];
783 $date = xl('for Encounter on') . ' ' . oeFormatShortDate(substr($enrow['date'], 0, 10));
784 $title = array(xl('Fee Sheet for'), text($name), text($date));
785 //echo join(" ", $title);
787 if ($GLOBALS['enable_help'] == 1) {
788 $help_icon = '<a class="pull-right oe-help-redirect" data-target="#myModal" data-toggle="modal" href="#" id="help-href" name="help-href" style="color:#676666" title="' . xl("Click to view Help") . '"><i class="fa fa-question-circle" aria-hidden="true"></i></a>';
789 } elseif ($GLOBALS['enable_help'] == 2) {
790 $help_icon = '<a class="pull-right oe-help-redirect" data-target="#myModal" data-toggle="modal" href="#" id="help-href" name="help-href" style="color:#DCD6D0 !Important" title="' . xl("Enable help in Administration > Globals > Features > Enable Help Modal") . '"><i class="fa fa-question-circle" aria-hidden="true"></i></a>';
791 } elseif ($GLOBALS['enable_help'] == 0) {
795 //to determine and set the form to open in the desired state - expanded or centered, any selection the user makes will
796 //become the user-specific default for that page. collectAndOrganizeExpandSetting() contains a single array as an
797 //argument, containing one or more elements, the name of the current file is the first element, if there are linked
798 // files they should be listed thereafter, please add _xpd suffix to the file name
799 $arr_files_php = array("fee_sheet_new_xpd");
800 $current_state = collectAndOrganizeExpandSetting($arr_files_php);
801 require_once("$srcdir/expand_contract_inc.php");
806 <body
class="body_top">
807 <div
class="<?php echo $container;?> expandable">
809 <div
class="col-sm-12">
810 <div
class="page-header clearfix">
811 <h2 id
="header_title" class="clearfix"><span id
='header_text'><?php
echo join(" ", $title); ?
></span
> <i id
="exp_cont_icon" class="fa <?php echo attr($expand_icon_class);?> oe-superscript-small expand_contract" title
="<?php echo attr($expand_title); ?>" aria
-hidden
="true"></i
><?php
echo $help_icon; ?
>
817 <div
class="col-sm-12">
818 <form method
="post" name
="fee_sheet_form" id
="fee_sheet_form" action
="<?php echo $rootdir; ?>/forms/fee_sheet/new.php?<?php
819 echo "rde
=" . urlencode($rapid_data_entry) . "&addmore
=" . urlencode($add_more_items); ?>"
820 onsubmit
="return validate(this)">
821 <input type
='hidden' name
='newcodes' value
=''>
823 $isBilled = !$add_more_items && isEncounterBilled($fs->pid
, $fs->encounter
);
825 echo "<p><font color='green'>" .
826 xlt("This encounter has been billed. To make changes, re-open it or select Add More Items.") .
828 } else { // the encounter is not yet billed
832 // Allow the patient price level to be fixed here.
834 echo "<legend>".xlt('Set Price Level')."</legend>";
835 echo "<div class='form-group text-center'>";
836 $plres = sqlStatement("SELECT option_id, title FROM list_options " .
837 "WHERE list_id = 'pricelevel' AND activity = 1 ORDER BY seq, title");
839 $pricelevel = $fs->getPriceLevel();
840 //echo " <span class='billcell'><b>" . xlt('Default Price Level') . ":</b></span>\n";
841 echo " <select name='pricelevel' class='center-block' style='width:250px'";
846 while ($plrow = sqlFetchArray($plres)) {
847 $key = $plrow['option_id'];
848 $val = $plrow['title'];
849 echo " <option value='" . attr($key) . "'";
850 if ($key == $pricelevel) {
853 echo ">" . text(xl_list_label($val)) . "</option>\n";
862 <legend
><?php
echo xlt("Select Code")?
></legend
>
863 <div
class='text-center'>
864 <table
class="table" width
=95%
>
869 // Create drop-lists based on the fee_sheet_options table.
870 $res = sqlStatement("SELECT * FROM fee_sheet_options " .
871 "ORDER BY fs_category, fs_option");
872 while ($row = sqlFetchArray($res)) {
873 $fs_category = $row['fs_category'];
874 $fs_option = $row['fs_option'];
875 $fs_codes = $row['fs_codes'];
876 if ($fs_category !== $last_category) {
878 $last_category = $fs_category;
880 // can cleave either one or two spaces from fs_category, fs_option to accomodate more than 9 custom categories
881 $cleave_cat = is_numeric(substr($fs_category, 0, 2)) ?
2 : 1;
882 $cleave_opt = is_numeric(substr($fs_option, 0, 2)) ?
2 : 1;
883 echo ($i <= 1) ?
" <tr>\n" : "";
884 echo " <td width='50%' nowrap>\n";
885 //echo " <td width='50%' align='center' nowrap>\n";
886 echo " <select style='width:96%' onchange='codeselect(this)'>\n";
887 echo " <option value=''> " . xlt(substr($fs_category, $cleave_cat)) . "</option>\n";
889 echo " <option value='" . attr($fs_codes) . "'>" . xlt(substr($fs_option, $cleave_opt)) . "</option>\n";
893 // Create drop-lists based on categories defined within the codes.
894 $pres = sqlStatement("SELECT option_id, title FROM list_options " .
895 "WHERE list_id = 'superbill' AND activity = 1 ORDER BY seq");
896 while ($prow = sqlFetchArray($pres)) {
899 echo ($i <= 1) ?
" <tr>\n" : "";
900 echo " <td width='50%' align='center' nowrap>\n";
901 echo " <select style='width:96%' onchange='codeselect(this)'>\n";
902 echo " <option value=''> " . text(xl_list_label($prow['title'])) . "\n";
903 $res = sqlStatement("SELECT code_type, code, code_text,modifier FROM codes " .
904 "WHERE superbill = ? AND active = 1 " .
905 "ORDER BY code_text", array($prow['option_id']));
906 while ($row = sqlFetchArray($res)) {
907 $ctkey = $fs->alphaCodeType($row['code_type']);
908 if ($code_types[$ctkey]['nofs']) {
911 echo " <option value='" . attr($ctkey) . "|" .
912 attr($row['code']) . ':'. attr($row['modifier']) . "|'>" . text($row['code_text']) . "</option>\n";
916 if ($i >= $FEE_SHEET_COLUMNS) {
922 // Create one more drop-list, for Products.
923 if ($GLOBALS['sell_non_drug_products']) {
925 echo ($i <= 1) ?
" <tr>\n" : "";
926 echo " <td width='50%' align='center' nowrap>\n";
927 echo " <select name='Products' style='width:96%' onchange='codeselect(this)'>\n";
928 echo " <option value=''> " . xlt('Products') . "\n";
929 $tres = sqlStatement("SELECT dt.drug_id, dt.selector, d.name " .
930 "FROM drug_templates AS dt, drugs AS d WHERE " .
931 "d.drug_id = dt.drug_id AND d.active = 1 AND d.consumable = 0 " .
932 "ORDER BY d.name, dt.selector, dt.drug_id");
933 while ($trow = sqlFetchArray($tres)) {
934 echo " <option value='PROD|" . attr($trow['drug_id']) . '|' . attr($trow['selector']) . "'>";
935 echo text($trow['name']);
936 if ($trow['name'] !== $trow['selector']) {
937 echo ' / ' . text($trow['selector']);
943 if ($i >= $FEE_SHEET_COLUMNS) {
949 $search_type = $default_search_type;
950 if ($_POST['search_type']) {
951 $search_type = $_POST['search_type'];
954 $ndc_applies = true; // Assume all payers require NDC info.
956 echo $i ?
" <td></td>\n </tr>\n" : "";
964 <legend
><?php
echo xlt("Search for Additional Codes")?
></legend
>
965 <div
class="col-lg-8 col-sm-12 text-center">
966 <div
class="form-group">
968 $nofs_code_types = array();
969 foreach ($code_types as $key => $value) {
970 if (!empty($value['nofs'])) {
973 $nofs_code_types[$key] = $value;
975 $size_select = (count($nofs_code_types) < 5) ?
count($nofs_code_types) : 5;
979 foreach ($nofs_code_types as $key => $value) {
980 echo"<label class='radio-inline'>";
981 echo " <input type='radio' name='search_type' value='" . attr($key) . "'";
982 if ($key == $search_type) {
985 echo " />" . xlt($value['label']) . " \n";
992 <div
class="col-lg-4 col-sm-12 clearfix">
993 <div
class="form-group clearfix">
994 <div
class="col-xs-8">
995 <input type
='text' class="form-control" name
='search_term' value
=''>
997 <div
class="col-xs-1">
998 <input type
='submit' name
='bn_search' value
='<?php echo xla('Search
');?>' onclick
='return this.clicked = true;'>
1004 <div
class="col-sm-12 text-center">
1006 echo "<td colspan='" . attr($FEE_SHEET_COLUMNS) . "' align='center' nowrap>\n";
1008 // If Search was clicked, do it and write the list of results here.
1009 // There's no limit on the number of results!
1012 if ($_POST['bn_search'] && $_POST['search_term']) {
1013 $res = main_code_set_search($search_type, $_POST['search_term']);
1015 $numrows = sqlNumRows($res);
1019 echo " <select name='Search Results' class='form-control'style='width:98%' " .
1020 "onchange='codeselect(this)' disabled >\n";
1022 echo " <select name='Search Results' style='width:98%; background:yellow' " .
1023 "onchange='codeselect(this)' >\n";
1026 echo " <option value=''> " . xlt("Search Results") . " ($numrows " . xlt("items") . ")\n";
1029 while ($row = sqlFetchArray($res)) {
1030 $code = $row['code'];
1031 if ($row['modifier']) {
1032 $code .= ":" . $row['modifier'];
1034 echo " <option value='" . attr($search_type) . "|" . attr($code) . "|'>" . text($code) . " " .
1035 text($row['code_text']) . "</option>\n";
1039 echo " </select>\n";
1044 <?php
} // end encounter not billed ?>
1046 <legend
><?php
echo xlt("Selected Fee Sheet Codes and Charges for Current Encounter")?
></legend
>
1047 <div
class='col-xs-12 '>
1049 <table
class = "table" name
='copay_review' id
='copay_review' >
1052 if ($fs->ALLOW_COPAYS
) {
1053 echo "<td class='col-md-6 pull-right'>";
1054 echo "<input type='button' value='". xla('Add Copay')."'";
1055 echo "onclick='copayselect()' />";
1061 <div
class='col-xs-12 text-center table-responsive'>
1062 <table name
='selected_codes' id
='selected_codes' class="table" cellspacing
='5'>
1064 <td
class='billcell'><b
><?php
echo xlt('Type');?
></b
></td
>
1065 <td
class='billcell'><b
><?php
echo xlt('Code');?
></b
></td
>
1066 <td
class='billcell'><b
><?php
echo xlt('Description');?
></b
></td
>
1067 <?php
if ($institutional) { ?
>
1068 <td
class='billcell'><b
><?php
echo xlt('Revenue');?
></b
></td
>
1070 <?php
if (modifiers_are_used(true)) { ?
>
1071 <td
class='billcell'><b
><?php
echo xlt('Modifiers');?
></b
></td
>
1073 <?php
if (fees_are_used()) { ?
>
1074 <?php
if ($price_levels_are_used) { ?
>
1075 <td
class='billcell' align
='center'><b
><?php
echo xlt('Price Level');?
></b
> 
;</td
>
1077 <td
class='billcell' align
='right'><b
><?php
echo xlt('Price');?
></b
> 
;</td
>
1078 <td
class='billcell' align
='center'><b
><?php
echo xlt('Units');?
></b
></td
>
1080 <?php
if (justifiers_are_used()) { ?
>
1081 <td
class='billcell' align
='center'<?php
echo $justifystyle; ?
>><b
><?php
echo xlt('Justify');?
></b
></td
>
1083 <td
class='billcell' align
='center' <?php
echo $liprovstyle; ?
>><b
><?php
echo xlt('Provider/Warehouse');?
></b
></td
>
1084 <td
class='billcell' align
='center'<?php
echo $usbillstyle; ?
>><b
><?php
echo xlt('Note Codes');?
></b
></td
>
1085 <td
class='billcell' align
='center'<?php
echo $usbillstyle; ?
>><b
><?php
echo xlt('Auth');?
></b
></td
>
1086 <?php
if ($GLOBALS['gbl_auto_create_rx']) { ?
>
1087 <td
class='billcell' align
='center'><b
><?php
echo xlt('Rx'); ?
></b
></td
>
1089 <td
class='billcell' align
='center'><b
><?php
echo xlt('Delete');?
></b
></td
>
1093 $justinit = "var f = document.forms[0];\n";
1095 // Generate lines for items already in the billing table for this encounter,
1096 // and also set the rendering provider if we come across one.
1100 foreach ($billresult as $iter) {
1101 if (!$ALLOW_COPAYS && $iter["code_type"] == 'COPAY') {
1104 if ($iter["code_type"] == 'TAX') {
1108 $bill_lino = count($fs->serviceitems
);
1109 $bline = $_POST['bill']["$bill_lino"];
1110 $del = $bline['del']; // preserve Delete if checked
1111 if ($institutional) {
1112 $revenue_code = trim($iter["revenue_code"]);
1114 $modifier = trim($iter["modifier"]);
1115 $units = $iter["units"];
1116 $fee = $iter["fee"];
1117 $authorized = $iter["authorized"];
1118 $ndc_info = $iter["ndc_info"];
1119 $justify = trim($iter['justify']);
1120 $notecodes = trim($iter['notecodes']);
1122 $justify = substr(str_replace(':', ',', $justify), 0, strlen($justify) - 1);
1124 $provider_id = $iter['provider_id'];
1126 // Also preserve other items from the form, if present.
1127 if ($bline['id'] && !$iter["billed"]) {
1128 if ($institutional) {
1129 //$revenue_code = trim($bline['revenue_code']);
1131 $modifier = trim($bline['mod']);
1132 $units = max(1, intval(trim($bline['units'])));
1133 $fee = formatMoneyNumber((0 +
trim($bline['price'])) * $units);
1134 $authorized = $bline['auth'];
1136 if ($bline['ndcnum']) {
1137 $ndc_info = 'N4' . trim($bline['ndcnum']) . ' ' . $bline['ndcuom'] .
1138 trim($bline['ndcqty']);
1140 $justify = $bline['justify'];
1141 $notecodes = trim($bline['notecodes']);
1142 $provider_id = 0 +
(int)$bline['provid'];
1145 if ($iter['code_type'] == 'COPAY') { // moved copay display to below
1149 $fs->addServiceLineItem(array(
1150 'codetype' => $iter['code_type'],
1151 'code' => trim($iter['code']),
1152 'revenue_code' => $revenue_code,
1153 'modifier' => $modifier,
1154 'ndc_info' => $ndc_info,
1155 'auth' => $authorized,
1158 'pricelevel' => $iter['pricelevel'],
1160 'id' => $iter['id'],
1161 'billed' => $iter['billed'],
1162 'code_text' => trim($iter['code_text']),
1163 'justify' => $justify,
1164 'provider_id' => $provider_id,
1165 'notecodes' => $notecodes,
1170 $resMoneyGot = sqlStatement(
1171 "SELECT pay_amount as PatientPay,session_id as id,date(post_time) as date ".
1172 "FROM ar_activity where pid =? and encounter =? and payer_type=0 and account_code='PCP'",
1173 array($fs->pid
, $fs->encounter
)
1174 ); //new fees screen copay gives account_code='PCP'
1175 while ($rowMoneyGot = sqlFetchArray($resMoneyGot)) {
1176 $PatientPay=$rowMoneyGot['PatientPay']*-1;
1177 $id=$rowMoneyGot['id'];
1178 $fs->addServiceLineItem(array(
1179 'codetype' => 'COPAY',
1182 'ndc_info' => $rowMoneyGot['date'],
1186 'fee' => $PatientPay,
1191 // Echo new billing items from this form here, but omit any line
1192 // whose Delete checkbox is checked.
1194 if ($_POST['bill']) {
1195 foreach ($_POST['bill'] as $key => $iter) {
1197 continue; // skip if it came from the database
1200 continue; // skip if Delete was checked
1203 if ($iter['ndcnum']) {
1204 $ndc_info = 'N4' . trim($iter['ndcnum']) . ' ' . $iter['ndcuom'] .
1205 trim($iter['ndcqty']);
1207 $units = max(1, intval(trim($iter['units'])));
1208 $fee = formatMoneyNumber((0 +
trim($iter['price'])) * $units);
1209 //the date is passed as $ndc_info, since this variable is not applicable in the case of copay.
1211 if ($iter['code_type'] == 'COPAY') {
1212 $ndc_info = date("Y-m-d");
1217 $fs->addServiceLineItem(array(
1218 'codetype' => $iter['code_type'],
1219 'code' => trim($iter['code']),
1220 'revenue_code' => $revenue_code,
1221 'modifier' => trim($iter["mod"]),
1222 'ndc_info' => $ndc_info,
1223 'auth' => $iter['auth'],
1224 'del' => $iter['del'],
1227 'justify' => $iter['justify'],
1228 'provider_id' => $iter['provid'],
1229 'notecodes' => $iter['notecodes'],
1230 'pricelevel' => $iter['pricelevel'],
1235 // Generate lines for items already in the drug_sales table for this encounter.
1237 $query = "SELECT ds.*, di.warehouse_id FROM drug_sales AS ds, drug_inventory AS di WHERE " .
1238 "ds.pid = ? AND ds.encounter = ? AND di.inventory_id = ds.inventory_id " .
1240 $sres = sqlStatement($query, array($fs->pid
, $fs->encounter
));
1242 while ($srow = sqlFetchArray($sres)) {
1244 $prod_lino = count($fs->productitems
);
1245 $pline = $_POST['prod']["$prod_lino"];
1246 $rx = !empty($srow['prescription_id']);
1247 $del = $pline['del']; // preserve Delete if checked
1248 $sale_id = $srow['sale_id'];
1249 $drug_id = $srow['drug_id'];
1250 $selector = $srow['selector'];
1251 $pricelevel = $srow['pricelevel'];
1252 $units = $srow['quantity'];
1253 $fee = $srow['fee'];
1254 $billed = $srow['billed'];
1255 $warehouse_id = $srow['warehouse_id'];
1256 // Also preserve other items from the form, if present and unbilled.
1257 if ($pline['sale_id'] && !$srow['billed']) {
1258 $units = max(1, intval(trim($pline['units'])));
1259 $fee = formatMoneyNumber((0 +
trim($pline['price'])) * $units);
1260 $rx = !empty($pline['rx']);
1262 $fs->addProductLineItem(array(
1263 'drug_id' => $drug_id,
1264 'selector' => $selector,
1265 'pricelevel' => $pricelevel,
1270 'sale_id' => $sale_id,
1271 'billed' => $billed,
1272 'warehouse_id' => $warehouse_id,
1276 // Echo new product items from this form here, but omit any line
1277 // whose Delete checkbox is checked.
1279 if ($_POST['prod']) {
1280 foreach ($_POST['prod'] as $key => $iter) {
1281 if ($iter["sale_id"]) {
1282 continue; // skip if it came from the database
1285 continue; // skip if Delete was checked
1287 $units = max(1, intval(trim($iter['units'])));
1288 $fee = formatMoneyNumber((0 +
trim($iter['price'])) * $units);
1289 $rx = !empty($iter['rx']); // preserve Rx if checked
1290 $warehouse_id = empty($iter['warehouse_id']) ?
'' : $iter['warehouse_id'];
1291 $fs->addProductLineItem(array(
1292 'drug_id' => $iter['drug_id'],
1293 'selector' => $iter['selector'],
1294 'pricelevel' => $iter['pricelevel'],
1298 'warehouse_id' => $warehouse_id,
1303 // If new billing code(s) were <select>ed, add their line(s) here.
1305 if ($_POST['newcodes'] && !$alertmsg) {
1306 $arrcodes = explode('~', $_POST['newcodes']);
1308 // A first pass here checks for any sex restriction errors.
1309 foreach ($arrcodes as $codestring) {
1310 if ($codestring === '') {
1313 list($newtype, $newcode) = explode('|', $codestring);
1314 if ($newtype == 'MA') {
1315 list($code, $modifier) = explode(":", $newcode);
1317 "SELECT sex FROM codes WHERE code_type = ? AND code = ? LIMIT 1",
1318 array($code_types[$newtype]['id'], $code)
1320 if ($tmp['sex'] == '1' && $fs->patient_male ||
$tmp['sex'] == '2' && !$fs->patient_male
) {
1321 $alertmsg = xl('Service is not compatible with the sex of this client.');
1327 foreach ($arrcodes as $codestring) {
1328 if ($codestring === '') {
1331 $arrcode = explode('|', $codestring);
1332 $newtype = $arrcode[0];
1333 $newcode = $arrcode[1];
1334 $newsel = $arrcode[2];
1335 if ($newtype == 'COPAY') {
1336 $tmp = sqlQuery("SELECT copay FROM insurance_data WHERE pid = ? " .
1337 "AND type = 'primary' ORDER BY date DESC LIMIT 1", array($fs->pid
));
1338 $code = formatMoneyNumber(0 +
$tmp['copay']);
1339 $fs->addServiceLineItem(array(
1340 'codetype' => $newtype,
1342 'ndc_info' => date('Y-m-d'),
1345 'fee' => formatMoneyNumber(0 - $code),
1347 } elseif ($newtype == 'PROD') {
1348 $result = sqlQuery("SELECT dt.quantity, d.route " .
1349 "FROM drug_templates AS dt, drugs AS d WHERE " .
1350 "dt.drug_id = ? AND dt.selector = ? AND " .
1351 "d.drug_id = dt.drug_id", array($newcode,$newsel));
1352 $units = max(1, intval($result['quantity']));
1353 // By default create a prescription if drug route is set.
1354 $rx = !empty($result['route']);
1355 $fs->addProductLineItem(array(
1356 'drug_id' => $newcode,
1357 'selector' => $newsel,
1362 list($code, $modifier) = explode(":", $newcode);
1364 // If HCPCS, find last NDC string used for this code.
1365 if ($newtype == 'HCPCS' && $ndc_applies) {
1366 $tmp = sqlQuery("SELECT ndc_info FROM billing WHERE " .
1367 "code_type = ? AND code = ? AND ndc_info LIKE 'N4%' " .
1368 "ORDER BY date DESC LIMIT 1", array($newtype,$code));
1370 $ndc_info = $tmp['ndc_info'];
1373 $fs->addServiceLineItem(array(
1374 'codetype' => $newtype,
1376 'modifier' => trim($modifier),
1377 'ndc_info' => $ndc_info,
1384 // Write the form's line items.
1387 // Ensure DOM is updated.
1388 echo "<script>reinitForm();</script>";
1396 <legend
><?php
echo xlt("Select Providers"); ?
></legend
>
1397 <div
class='col-xs-12'>
1398 <div
class="form-group col-lg-6 col-sm-12">
1399 <label
class="control-label col-lg-4 col-sm-3 text-left"><?php
echo xlt('Rendering'); ?
></label
>
1401 if ($GLOBALS['default_rendering_provider'] == '0') {
1403 } elseif ($GLOBALS['default_rendering_provider'] == '1') {
1404 $default_rid = $fs->provider_id
;
1406 $default_rid = isset($_SESSION['authUserID']) ?
$_SESSION['authUserID'] : $fs->provider_id
;
1408 echo $fs->genProviderSelect('ProviderID', '-- ' . xl("Please Select") . ' --', $default_rid, $isBilled);
1411 <div
class="form-group col-lg-6 col-sm-12">
1413 if (!$GLOBALS['ippf_specific']) { ?
>
1414 <label
class='control-label col-lg-4 col-sm-3 text-left'> <?php
echo xlt('Supervising'); ?
> </label
>
1415 <?php
echo $fs->genProviderSelect('SupervisorID', '-- '.xl("N/A").' --', $fs->supervisor_id
, $isBilled);
1423 if ($fs->contraception_code
&& !$isBilled) {
1424 // This will give the form save logic the associated contraceptive method.
1425 echo "<input type='hidden' name='ippfconmeth' value='" . attr($fs->contraception_code
) . "'>\n";
1426 // If needed, this generates a dropdown to ask about prior contraception.
1427 echo $fs->generateContraceptionSelector();
1431 <!-- 
;  
;  
;-->
1432 <div
class="form-group">
1433 <div
class="col-sm-12 position-override">
1434 <div
class="btn-group oe-opt-btn-group-pinch" role
="group">
1435 <button type
='button' class='btn btn-default btn-calendar' onclick
='newEvt()'><?php
echo xlt('New Appointment');?
></button
>
1436 <?php
if (!$isBilled) { // visit is not yet billed ?>
1437 <button type
='submit' name
='bn_refresh' class='btn btn-default btn-refresh' value
='<?php echo xla('Refresh
');?>' onclick
='return this.clicked = true;'><?php
echo xlt('Refresh');?
></button
>
1438 <button type
='submit' name
='bn_save' class='btn btn-default btn-save' value
='<?php echo xla('Save
');?>'
1440 if ($rapid_data_entry) {
1441 echo " style='background-color:#cc0000';color:#ffffff'";
1442 } ?
>><?php
echo xla('Save');?
></button
>
1443 <button type
='submit' name
='bn_save_stay' class='btn btn-default btn-save' value
='<?php echo xla('Save Current
'); ?>'><?php
echo xlt('Save Current'); ?
></button
>
1444 <?php
if ($GLOBALS['ippf_specific']) { // start ippf-only stuff ?>
1445 <?php
if ($fs->hasCharges
) { // unbilled with charges ?>
1446 <button type
='submit' name
='bn_save_close' class='btn btn-default btn-save' value
='<?php echo xla('Save
and Checkout
'); ?>'><?php
echo xlt('Save and Checkout'); ?
></button
>
1447 <?php
} else { // unbilled with no charges ?>
1448 <button type
='submit' name
='bn_save_close' class='btn btn-default btn-save'value
='<?php echo xla('Save
and Close
'); ?>'><?php
echo xlt('Save and Close'); ?
></button
>
1449 <?php
} // end no charges ?>
1450 <?php
} // end ippf-only ?>
1451 <?php
} else { // visit is billed ?>
1452 <?php
if ($fs->hasCharges
) { // billed with charges ?>
1453 <button type
='button' class='btn btn-default btn-show'
1454 onclick
="top.restoreSession();location='../../patient_file/pos_checkout.php?framed=1<?php
1455 echo "&ptid
=" . urlencode($fs->pid) . "&enc
=" . urlencode($fs->encounter); ?>'" value
='<?php echo xla('Show Receipt
'); ?>'><?php
echo xlt('Show Receipt'); ?
></button
>
1456 <button type
='submit' class='btn btn-default btn-undo' name
='bn_reopen' onclick
='return this.clicked = 2;' value
='<?php echo xla('Void Checkout
and Re
-Open
'); ?>'>
1457 <?php
echo xlt('Void Checkout and Re-Open'); ?
></button
>
1459 <button type
='submit' class='btn btn-default btn-undo' name
='bn_reopen' onclick
='return this.clicked = true;' value
='<?php echo xla('Re
-Open Visit
'); ?>'>
1460 <?php
echo xlt('Re-Open Visit'); ?
></button
>
1461 <?php
} // end billed without charges ?>
1462 <button type
='submit' class='btn btn-default btn-add' name
='bn_addmore' onclick
='return this.clicked = true;' value
='<?php echo xla('Add More Items
'); ?>'>
1463 <?php
echo xlt('Add More Items'); ?
></button
>
1464 <?php
} // end billed ?>
1465 <button type
='button' class='btn btn-link btn-cancel btn-separate-left'onclick
="top.restoreSession();location='<?php echo $GLOBALS['form_exit_url']; ?>'">
1466 <?php
echo xlt('Cancel');?
></button
>
1467 <input type
='hidden' name
='form_has_charges' value
='<?php echo $fs->hasCharges ? 1 : 0; ?>' />
1468 <input type
='hidden' name
='form_checksum' value
='<?php echo $current_checksum; ?>' />
1469 <input type
='hidden' name
='form_alertmsg' value
='<?php echo attr($alertmsg); ?>' />
1478 </div
><!--End of div container
-->
1480 //home of the help modal ;)
1481 //$GLOBALS['enable_help'] = 0; // Please comment out line if you want help modal to function on this page
1482 if ($GLOBALS['enable_help'] == 1) {
1483 echo "<script>var helpFile = 'fee_sheet_help.php'</script>";
1484 //help_modal.php lives in interface, set path accordingly
1485 require_once "../../help_modal.php";
1489 $
( document
).ready(function() {
1490 $
('select').addClass("form-control");
1493 <script type
="text/javascript">
1498 echo "alert('" . addslashes($alertmsg) . "');\n";
1505 // jQuery script to change expanded/centered state dynamically
1506 require_once("../../expand_contract_js.php")
1512 <?php
if (!empty($_POST['running_as_ajax'])) {
1515 <?php
require_once("review/initialize_review.php"); ?
>
1516 <?php
require_once("code_choice/initialize_code_choice.php"); ?
>
1517 <?php
if ($GLOBALS['ippf_specific']) {
1518 require_once("contraception_products/initialize_contraception_products.php");
1521 var translated_price_header
="<?php echo xlt("Price
");?>";
1523 $
( "[name='search_term']" ).keydown(function(event
){
1524 if(event
.keyCode
==13){
1525 $
("[name=bn_search]").trigger('click');
1530 $
("[name=search_term]").focus();
1534 $search_term = $_POST['search_term'];
1535 if ($numrows && $_POST['bn_search']) {
1537 echo "alert( $numrows + ' " . xls('results returned for search term') . " \"" . attr($search_term) . "\"')";
1539 } elseif (!$nnumrows && $_POST['bn_search']) {
1541 echo "alert('" . xls('No results returned for search term') . " \"". attr($search_term) ."\". " . xls('Please try a different search') . "')";