leaned down jquery versions
[openemr.git] / interface / forms / fee_sheet / new.php
blob92b166266b8189bb6bb644bccccc9e979c9f7472
1 <?php
2 /*
3 * Fee Sheet Program used to create charges, copays and add diagnosis codes to the encounter
5 * Copyright (C) 2005-2016 Rod Roark <rod@sunsetsystems.com>
7 * LICENSE: This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 3
10 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
18 * @package OpenEMR
19 * @author Rod Roark <rod@sunsetsystems.com>
20 * @author Terry Hill <terry@lillysystems.com>
21 * @link http://www.open-emr.org
27 require_once("../../globals.php");
28 require_once("$srcdir/FeeSheetHtml.class.php");
29 require_once("codes.php");
31 // Some table cells will not be displayed unless insurance billing is used.
32 $usbillstyle = $GLOBALS['ippf_specific'] ? " style='display:none'" : "";
33 $justifystyle = justifiers_are_used() ? "" : " style='display:none'";
35 $liprovstyle = (isset($GLOBALS['support_fee_sheet_line_item_provider']) &&
36 $GLOBALS['support_fee_sheet_line_item_provider'] != 1) ? " style='display:none'" : "";
38 // This flag comes from the LBFmsivd form and perhaps later others.
39 $rapid_data_entry = empty($_GET['rde']) ? 0 : 1;
41 // This comes from the Add More Items button, or is preserved from its previous value.
42 $add_more_items = (empty($_GET['addmore']) && empty($_POST['bn_addmore'])) ? 0 : 1;
44 $alertmsg = '';
46 // Determine if more than one price level is in use.
47 $tmp = sqlQuery("SELECT COUNT(*) AS count FROM list_options where list_id = 'pricelevel' AND activity = 1");
48 $price_levels_are_used = $tmp['count'] > 1;
50 // Format a money amount with decimals but no other decoration.
51 // Second argument is used when extra precision is required.
52 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() {
58 global $i, $last_category, $FEE_SHEET_COLUMNS;
59 if (! $last_category) return;
60 echo " </select>\n";
61 echo " </td>\n";
62 if ($i >= $FEE_SHEET_COLUMNS) {
63 echo " </tr>\n";
64 $i = 0;
68 // Generate JavaScript to build the array of diagnoses.
69 function genDiagJS($code_type, $code) {
70 global $code_types;
71 if ($code_types[$code_type]['diag']) {
72 echo "diags.push('" . attr($code_type) . "|" . attr($code) . "');\n";
76 // Write all service lines to the web form.
78 function echoServiceLines() {
79 global $code_types, $justinit, $usbillstyle, $liprovstyle, $justifystyle, $fs, $price_levels_are_used;
81 foreach ($fs->serviceitems as $lino => $li) {
82 $id = $li['hidden']['id'];
83 $codetype = $li['hidden']['code_type'];
84 $code = $li['hidden']['code'];
85 $modifier = $li['hidden']['mod'];
86 $billed = $li['hidden']['billed'];
87 $ndc_info = isset($li['ndc_info']) ? $li['ndc_info'] : '';
88 $pricelevel = $li['pricelevel'];
89 $justify = $li['justify'];
91 $strike1 = $li['del'] ? "<strike>" : "";
92 $strike2 = $li['del'] ? "</strike>" : "";
94 echo " <tr>\n";
96 echo " <td class='billcell'>$strike1" .
97 ($codetype == 'COPAY' ? xl($codetype) : $codetype) . $strike2;
98 // if the line to ouput is copay, show the date here passed as $ndc_info,
99 // since this variable is not applicable in the case of copay.
100 if ($codetype == 'COPAY') {
101 echo "(" . text($ndc_info) . ")";
102 $ndc_info = '';
104 if ($id) {
105 echo "<input type='hidden' name='bill[" . attr($lino) . "][id]' value='$id' />";
107 echo "<input type='hidden' name='bill[" . attr($lino) . "][code_type]' value='" . attr($codetype) . "' />";
108 echo "<input type='hidden' name='bill[" . attr($lino) . "][code]' value='" . attr($code) . "' />";
109 echo "<input type='hidden' name='bill[" . attr($lino)."][billed]' value='" . attr($billed)."' />";
110 if (isset($li['hidden']['method'])) {
111 echo "<input type='hidden' name='bill[$lino][method]' value='" . attr($li['hidden']['method' ]) . "' />";
112 echo "<input type='hidden' name='bill[$lino][cyp]' value='" . attr($li['hidden']['cyp' ]) . "' />";
113 echo "<input type='hidden' name='bill[$lino][methtype]' value='" . attr($li['hidden']['methtype']) . "' />";
115 echo "</td>\n";
117 if ($codetype != 'COPAY') {
118 echo " <td class='billcell'>$strike1" . text($code) . "$strike2</td>\n";
119 } else {
120 echo " <td class='billcell'>&nbsp;</td>\n";
123 echo " <td class='billcell'>$strike1" . text($li['code_text']) . "$strike2</td>\n";
125 if ($billed) {
127 if (modifiers_are_used(true)) {
128 echo " <td class='billcell'>$strike1" . text($modifier) . "$strike2" .
129 "<input type='hidden' name='bill[" . attr($lino) . "][mod]' value='" . attr($modifier) . "'></td>\n";
132 if (fees_are_used()) {
133 if ($price_levels_are_used) {
134 // Show price level for this line.
135 echo " <td class='billcell' align='center'>";
136 echo $fs->genPriceLevelSelect('', ' ', $li['hidden']['codes_id'], '', $pricelevel, true);
137 echo "</td>\n";
139 echo " <td class='billcell' align='right'>" . text(oeFormatMoney($li['price'])) . "</td>\n";
140 if ($codetype != 'COPAY') {
141 echo " <td class='billcell' align='center'>" . text($li['units']) . "</td>\n";
142 } else {
143 echo " <td class='billcell'>&nbsp;</td>\n";
145 echo " <td class='billcell' align='center'$justifystyle>$justify</td>\n";
148 // Show provider for this line.
149 echo " <td class='billcell' align='center' $liprovstyle>";
150 echo $fs->genProviderSelect('', '-- ' .xl("Default"). ' --', $li['provid'], true);
151 echo "</td>\n";
153 if ($code_types[$codetype]['claim'] && !$code_types[$codetype]['diag']) {
154 echo " <td class='billcell' align='center'$usbillstyle>" .
155 text($li['notecodes']) . "</td>\n";
157 else {
158 echo " <td class='billcell' align='center'$usbillstyle></td>\n";
161 echo " <td class='billcell' align='center'$usbillstyle><input type='checkbox'" .
162 ($li['auth'] ? " checked" : "") . " disabled /></td>\n";
164 if ($GLOBALS['gbl_auto_create_rx']) {
165 echo " <td class='billcell' align='center'>&nbsp;</td>\n";
168 echo " <td class='billcell' align='center'><input type='checkbox'" .
169 " disabled /></td>\n";
172 else { // not billed
174 if (modifiers_are_used(true)) {
175 if ($codetype != 'COPAY' && ($code_types[$codetype]['mod'] || $modifier)) {
176 echo " <td class='billcell'><input type='text' name='bill[" . attr($lino) . "][mod]' " .
177 "title='" . xla("Multiple modifiers can be separated by colons or spaces, maximum of 4 (M1:M2:M3:M4)") . "' " .
178 "value='" . attr($modifier) . "' size='" . attr($code_types[$codetype]['mod']) . "'></td>\n";
179 } else {
180 echo " <td class='billcell'>&nbsp;</td>\n";
183 if (fees_are_used()) {
184 if ($codetype == 'COPAY' || $code_types[$codetype]['fee'] || $fee != 0) {
185 if ($price_levels_are_used) {
186 echo " <td class='billcell' align='center'>";
187 echo $fs->genPriceLevelSelect("bill[$lino][pricelevel]", ' ', $li['hidden']['codes_id'], '', $pricelevel);
188 echo "</td>\n";
190 echo " <td class='billcell' align='right'>" .
191 "<input type='text' name='bill[$lino][price]' " .
192 "value='" . attr($li['price']) . "' size='6' onchange='setSaveAndClose()'";
193 if (acl_check('acct','disc'))
194 echo " style='text-align:right'";
195 else
196 echo " style='text-align:right;background-color:transparent' readonly";
197 echo "></td>\n";
199 echo " <td class='billcell' align='center'>";
200 if ($codetype != 'COPAY') {
201 echo "<input type='text' name='bill[" . attr($lino) . "][units]' " .
202 "value='" . attr($li['units']) . "' size='2' style='text-align:right'>";
203 } else {
204 echo "<input type='hidden' name='bill[" . attr($lino) . "][units]' value='" . attr($li['units']) . "'>";
206 echo "</td>\n";
208 if ($code_types[$codetype]['just'] || $li['justify']) {
209 echo " <td class='billcell' align='center'$justifystyle>";
210 echo "<select name='bill[" . attr($lino) . "][justify]' onchange='setJustify(this)'>";
211 echo "<option value='" . attr($li['justify']) . "'>" . text($li['justify']) . "</option></select>";
212 echo "</td>\n";
213 $justinit .= "setJustify(f['bill[" . attr($lino) . "][justify]']);\n";
214 } else {
215 echo " <td class='billcell'$justifystyle>&nbsp;</td>\n";
217 } else {
218 if ($price_levels_are_used) echo " <td class='billcell'>&nbsp;</td>\n";
219 echo " <td class='billcell'>&nbsp;</td>\n";
220 echo " <td class='billcell'>&nbsp;</td>\n";
221 echo " <td class='billcell'$justifystyle>&nbsp;</td>\n"; // justify
225 // Provider drop-list for this line.
226 echo " <td class='billcell' align='center' $liprovstyle>";
227 echo $fs->genProviderSelect("bill[$lino][provid]", '-- '.xl("Default").' --', $li['provid']);
228 echo "</td>\n";
230 if ($code_types[$codetype]['claim'] && !$code_types[$codetype]['diag']) {
231 echo " <td class='billcell' align='center'$usbillstyle><input type='text' name='bill[" . attr($lino) . "][notecodes]' " .
232 "value='" . text($li['notecodes']) . "' maxlength='10' size='8' /></td>\n";
234 else {
235 echo " <td class='billcell' align='center'$usbillstyle></td>\n";
238 echo " <td class='billcell' align='center'$usbillstyle><input type='checkbox' name='bill[".attr($lino) . "][auth]' " .
239 "value='1'" . ($li['auth'] ? " checked" : "") . " /></td>\n";
241 if ($GLOBALS['gbl_auto_create_rx']) {
242 echo " <td class='billcell' align='center'>&nbsp;</td>\n"; // KHY: May need to confirm proper location of this cell
245 echo " <td class='billcell' align='center'><input type='checkbox' name='bill[" . attr($lino) . "][del]' " .
246 "value='1'" . ($li['del'] ? " checked" : "") . " /></td>\n";
249 echo " </tr>\n";
251 // If NDC info exists or may be required, add a line for it.
252 if (isset($li['ndcnum'])) {
253 echo " <tr>\n";
254 echo " <td class='billcell' colspan='2'>&nbsp;</td>\n";
255 echo " <td class='billcell' colspan='6'>&nbsp;NDC:&nbsp;";
256 echo "<input type='text' name='bill[" . attr($lino) . "][ndcnum]' value='" . attr($li['ndcnum']) . "' " .
257 "size='11' style='background-color:transparent'>";
258 echo " &nbsp;Qty:&nbsp;";
259 echo "<input type='text' name='bill[" . attr($lino) . "][ndcqty]' value='" . attr($li['ndcqty']) . "' " .
260 "size='3' style='background-color:transparent;text-align:right'>";
261 echo " ";
262 echo "<select name='bill[" . attr($lino) . "][ndcuom]' style='background-color:transparent'>";
263 foreach ($fs->ndc_uom_choices as $key => $value) {
264 echo "<option value='" . attr($key) . "'";
265 if ($key == $li['ndcuom']) echo " selected";
266 echo ">" . text($value) . "</option>";
268 echo "</select>";
269 echo "</td>\n";
270 echo " </tr>\n";
272 else if (!empty($li['ndc_info'])) {
273 echo " <tr>\n";
274 echo " <td class='billcell' colspan='2'>&nbsp;</td>\n";
275 echo " <td class='billcell' colspan='6'>&nbsp;" . xlt("NDC Data") . ": " . text($li['ndc_info']) . "</td>\n";
276 echo " </tr>\n";
281 // Write all product lines to the web form.
283 function echoProductLines() {
284 global $code_types, $usbillstyle, $liprovstyle, $justifystyle, $fs, $price_levels_are_used;
286 foreach ($fs->productitems as $lino => $li) {
287 $drug_id = $li['hidden']['drug_id'];
288 $selector = $li['hidden']['selector'];
289 $sale_id = $li['hidden']['sale_id'];
290 $billed = $li['hidden']['billed'];
291 $fee = $li['fee'];
292 $price = $li['price'];
293 $pricelevel = $li['pricelevel'];
294 $units = $li['units'];
295 $del = $li['del'];
296 $warehouse_id = $li['warehouse'];
297 $rx = $li['rx'];
299 $strike1 = ($sale_id && $del) ? "<strike>" : "";
300 $strike2 = ($sale_id && $del) ? "</strike>" : "";
302 echo " <tr>\n";
303 echo " <td class='billcell'>{$strike1}" . xlt("Product") . "$strike2";
304 echo "<input type='hidden' name='prod[" . attr($lino) . "][sale_id]' value='" . attr($sale_id) . "'>";
305 echo "<input type='hidden' name='prod[" . attr($lino) . "][drug_id]' value='" . attr($drug_id) . "'>";
306 echo "<input type='hidden' name='prod[" . attr($lino) . "][selector]' value='" . attr($selector) . "'>";
307 echo "<input type='hidden' name='prod[" . attr($lino) . "][billed]' value='" . attr($billed) . "'>";
308 if (isset($li['hidden']['method'])) {
309 echo "<input type='hidden' name='prod[$lino][method]' value='" . attr($li['hidden']['method' ]) . "' />";
310 echo "<input type='hidden' name='prod[$lino][methtype]' value='" . attr($li['hidden']['methtype']) . "' />";
312 echo "</td>\n";
314 echo " <td class='billcell'>$strike1" . text($drug_id) . "$strike2</td>\n";
316 echo " <td class='billcell'>$strike1" . text($li['code_text']) . "$strike2</td>\n";
318 if (modifiers_are_used(true)) {
319 echo " <td class='billcell'>&nbsp;</td>\n";
322 if ($billed) {
323 if (fees_are_used()) {
324 if ($price_levels_are_used) {
325 echo " <td class='billcell' align='center'>";
326 echo $fs->genPriceLevelSelect('', ' ', $drug_id, $selector, $pricelevel, true);
327 echo "</td>\n";
329 echo " <td class='billcell' align='right'>" . text(oeFormatMoney($price)) . "</td>\n";
330 echo " <td class='billcell' align='center'>" . text($units) . "</td>\n";
332 if (justifiers_are_used()) { // KHY Evaluate proper position/usage of if justifiers
333 echo " <td class='billcell' align='center'$justifystyle>&nbsp;</td>\n"; // justify
335 // Show warehouse for this line.
336 echo " <td class='billcell' align='center' $liprovstyle>";
337 echo $fs->genWarehouseSelect('', ' ', $warehouse_id, true, $drug_id, $sale_id > 0);
338 echo "</td>\n";
340 echo " <td class='billcell' align='center'$usbillstyle>&nbsp;</td>\n"; // note codes
341 echo " <td class='billcell' align='center'$usbillstyle>&nbsp;</td>\n"; // auth
342 if ($GLOBALS['gbl_auto_create_rx']) {
343 echo " <td class='billcell' align='center'><input type='checkbox'" . // rx
344 " disabled /></td>\n";
346 echo " <td class='billcell' align='center'><input type='checkbox'" . // del
347 " disabled /></td>\n";
350 else { // not billed
351 if (fees_are_used()) {
352 if ($price_levels_are_used) {
353 echo " <td class='billcell' align='center'>";
354 echo $fs->genPriceLevelSelect("prod[$lino][pricelevel]", ' ', $drug_id, $selector, $pricelevel);
355 echo "</td>\n";
357 echo " <td class='billcell' align='right'>" .
358 "<input type='text' name='prod[" . attr($lino) . "][price]' " .
359 "value='" . attr($price) . "' size='6' onchange='setSaveAndClose()'";
360 if (acl_check('acct','disc'))
361 echo " style='text-align:right'";
362 else
363 echo " style='text-align:right;background-color:transparent' readonly";
364 echo "></td>\n";
365 echo " <td class='billcell' align='center'>";
366 echo "<input type='text' name='prod[" . attr($lino) . "][units]' " .
367 "value='" . attr($units) . "' size='2' style='text-align:right'>";
368 echo "</td>\n";
370 if (justifiers_are_used()) {
371 echo " <td class='billcell'$justifystyle>&nbsp;</td>\n"; // justify
373 // Generate warehouse selector if there is a choice of warehouses.
374 echo " <td class='billcell' align='center' $liprovstyle>";
375 echo $fs->genWarehouseSelect("prod[$lino][warehouse]", ' ', $warehouse_id, false, $drug_id, $sale_id > 0);
376 echo "</td>\n";
378 echo " <td class='billcell' align='center'$usbillstyle>&nbsp;</td>\n"; // note codes
379 echo " <td class='billcell' align='center'$usbillstyle>&nbsp;</td>\n"; // auth
380 if ($GLOBALS['gbl_auto_create_rx']) {
381 echo " <td class='billcell' align='center'>" .
382 "<input type='checkbox' name='prod[$lino][rx]' value='1'" .
383 ($rx ? " checked" : "") . " /></td>\n";
385 echo " <td class='billcell' align='center'><input type='checkbox' name='prod[" . attr($lino) . "][del]' " .
386 "value='1'" . ($del ? " checked" : "") . " /></td>\n";
389 echo " </tr>\n";
393 $fs = new FeeSheetHtml();
395 // $FEE_SHEET_COLUMNS should be defined in codes.php.
396 if (empty($FEE_SHEET_COLUMNS)) $FEE_SHEET_COLUMNS = 2;
398 // Update price level in patient demographics if it's changed.
399 if (!empty($_POST['pricelevel'])) {
400 $fs->updatePriceLevel($_POST['pricelevel']);
403 $current_checksum = $fs->visitChecksum();
404 // It's important to look for a checksum mismatch even if we're just refreshing
405 // the display, otherwise the error goes undetected on a refresh-then-save.
406 if (isset($_POST['form_checksum'])) {
407 if ($_POST['form_checksum'] != $current_checksum) {
408 $alertmsg = xl('Someone else has just changed this visit. Please cancel this page and try again.');
409 $comment = "CHECKSUM ERROR, expecting '{$_POST['form_checksum']}'";
410 newEvent("checksum", $_SESSION['authUser'], $_SESSION['authProvider'], 1, $comment, $pid);
414 if (!$alertmsg && ($_POST['bn_save'] || $_POST['bn_save_close'])) {
415 $alertmsg = $fs->checkInventory($_POST['prod']);
418 // If Save or Save-and-Close was clicked, save the new and modified billing
419 // lines; then if no error, redirect to $GLOBALS['form_exit_url'].
421 if (!$alertmsg && ($_POST['bn_save'] || $_POST['bn_save_close'])) {
422 $main_provid = 0 + $_POST['ProviderID'];
423 $main_supid = 0 + $_POST['SupervisorID'];
425 $fs->save($_POST['bill'], $_POST['prod'], $main_provid, $main_supid,
426 $_POST['default_warehouse'], $_POST['bn_save_close']);
428 // Note: Taxes are computed at checkout time (in pos_checkout.php which
429 // also posts to SL). Currently taxes with insurance claims make no sense,
430 // so for now we'll ignore tax computation in the insurance billing logic.
432 if ($_POST['running_as_ajax']) {
433 // In the case of running as an AJAX handler, we need to return this same
434 // form with an updated checksum to properly support the invoking logic.
435 // See review/js/fee_sheet_core.js for that logic.
436 $current_checksum = $fs->visitChecksum(true);
437 // Also remove form data for the newly entered lines so they are not
438 // duplicated from the database.
439 unset($_POST['bill']);
440 unset($_POST['prod']);
442 else { // not running as ajax
443 // If appropriate, update the status of the related appointment to
444 // "In exam room".
445 updateAppointmentStatus($fs->pid, $fs->visit_date, '<');
447 // More Family Planning stuff.
448 if (isset($_POST['ippfconmeth'])) {
449 $tmp_form_id = $fs->doContraceptionForm($_POST['ippfconmeth'], $_POST['newmauser'], $main_provid);
450 if ($tmp_form_id) {
451 // Contraceptive method does not match what is in an existing Contraception
452 // form for this visit, or there is no such form. Open the form.
453 formJump("{$GLOBALS['rootdir']}/patient_file/encounter/view_form.php" .
454 "?formname=LBFccicon&id=" . ($tmp_form_id < 0 ? 0 : $tmp_form_id));
455 formFooter();
456 exit;
460 if ($rapid_data_entry || ($_POST['bn_save_close'] && $_POST['form_has_charges'])) {
461 // In rapid data entry mode or if "Save and Checkout" was clicked,
462 // we go directly to the Checkout page.
463 formJump("{$GLOBALS['rootdir']}/patient_file/pos_checkout.php?framed=1" .
464 "&ptid={$fs->pid}&enid={$fs->encounter}&rde=$rapid_data_entry");
466 else {
467 // Otherwise return to the normal encounter summary frameset.
468 formHeader("Redirecting....");
469 formJump();
471 formFooter();
472 exit;
473 } // end not running as ajax
474 } // end save or save-and-close
476 // Handle reopen request. In that case no other changes will be saved.
477 // If there was a checkout this will undo it.
478 if (!$alertmsg && $_POST['bn_reopen']) {
479 doVoid($fs->pid, $fs->encounter, true);
480 $current_checksum = $fs->visitChecksum();
481 // Remove the line items so they are refreshed from the database on redisplay.
482 unset($_POST['bill']);
483 unset($_POST['prod']);
486 $billresult = getBillingByEncounter($fs->pid, $fs->encounter, "*");
488 <html>
489 <head>
490 <?php html_header_show(); ?>
491 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
492 <style>
493 .billcell { font-family: sans-serif; font-size: 10pt }
494 </style>
496 <script type="text/JavaScript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-3-1-1/index.js"></script>
497 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/knockout-3-4-0/dist/knockout.js"></script>
498 <script type="text/javascript" src="../../../library/textformat.js?v=<?php echo $v_js_includes; ?>"></script>
499 <script type="text/javascript" src="../../../library/dialog.js?v=<?php echo $v_js_includes; ?>"></script>
501 <script language="JavaScript">
503 var mypcc = '<?php echo $GLOBALS['phone_country_code'] ?>';
505 var diags = new Array();
507 <?php
508 if ($billresult) {
509 foreach ($billresult as $iter) {
510 genDiagJS($iter["code_type"], trim($iter["code"]));
513 if ($_POST['bill']) {
514 foreach ($_POST['bill'] as $iter) {
515 if ($iter["del"]) continue; // skip if Delete was checked
516 if ($iter["id"]) continue; // skip if it came from the database
517 genDiagJS($iter["code_type"], $iter["code"]);
520 if ($_POST['newcodes']) {
521 $arrcodes = explode('~', $_POST['newcodes']);
522 foreach ($arrcodes as $codestring) {
523 if ($codestring === '') continue;
524 $arrcode = explode('|', $codestring);
525 list($code, $modifier) = explode(":", $arrcode[1]);
526 genDiagJS($arrcode[0], $code);
531 // This is invoked by <select onchange> for the various dropdowns,
532 // including search results.
533 function codeselect(selobj) {
534 var i = selobj ? selobj.selectedIndex : -1;
535 if (i) {
536 top.restoreSession();
537 var f = document.forms[0];
538 if (selobj) f.newcodes.value = selobj.options[i].value;
539 f.submit();
543 function copayselect() {
544 top.restoreSession();
545 var f = document.forms[0];
546 f.newcodes.value = 'COPAY||';
547 f.submit();
550 <?php echo $fs->jsLineItemValidation(); ?>
552 function validate(f) {
553 if (f.bn_reopen) {
554 var reopening = f.bn_reopen.clicked;
555 var voiding = reopening && f.bn_reopen.clicked == 2;
556 f.bn_reopen.clicked = false;
557 if (reopening) {
558 if (voiding) {
559 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?'); ?>')) {
560 return false;
563 top.restoreSession();
564 return true;
567 var refreshing = false;
568 if (f.bn_refresh) {
569 refreshing = f.bn_refresh.clicked ? true : false;
570 f.bn_refresh.clicked = false;
572 if (f.bn_addmore) {
573 refreshing = refreshing || f.bn_addmore.clicked;
574 f.bn_addmore.clicked = false;
576 var searching = false;
577 if (f.bn_search) {
578 searching = f.bn_search.clicked ? true : false;
579 f.bn_search.clicked = false;
581 if (!refreshing && !searching) {
582 if (!jsLineItemValidation(f)) return false;
584 top.restoreSession();
585 return true;
588 // When a justify selection is made, apply it to the current list for
589 // this procedure and then rebuild its selection list.
591 function setJustify(seljust) {
592 var theopts = seljust.options;
593 var jdisplay = theopts[0].text;
594 // Compute revised justification string. Note this does nothing if
595 // the first entry is still selected, which is handy at startup.
596 if (seljust.selectedIndex > 0) {
597 var newdiag = seljust.value;
598 if (newdiag.length == 0) {
599 jdisplay = '';
601 else {
602 if (jdisplay.length) jdisplay += ',';
603 jdisplay += newdiag;
606 // Rebuild selection list.
607 var jhaystack = ',' + jdisplay + ',';
608 var j = 0;
609 theopts.length = 0;
610 theopts[j++] = new Option(jdisplay,jdisplay,true,true);
611 for (var i = 0; i < diags.length; ++i) {
612 if (jhaystack.indexOf(',' + diags[i] + ',') < 0) {
613 theopts[j++] = new Option(diags[i],diags[i],false,false);
616 theopts[j++] = new Option('Clear','',false,false);
619 // Determine if there are any charges in this visit.
620 function hasCharges() {
621 var f = document.forms[0];
622 for (var i = 0; i < f.elements.length; ++i) {
623 var elem = f.elements[i];
624 if (elem.name.indexOf('[price]') > 0) {
625 var fee = Number(elem.value);
626 if (!isNaN(fee) && fee != 0) return true;
629 return false;
632 // Function to check if there are any charges in the form, and to enable
633 // or disable the Save and Close button accordingly.
635 function setSaveAndClose() {
636 var f = document.forms[0];
637 if (!f.bn_save_close) return;
638 if (hasCharges()) {
639 f.form_has_charges.value = '1';
640 f.bn_save_close.value = '<?php echo xla('Save and Checkout'); ?>';
642 else {
643 f.form_has_charges.value = '0';
644 f.bn_save_close.value = '<?php echo xla('Save and Close'); ?>';
648 // Open the add-event dialog.
649 function newEvt() {
650 var f = document.forms[0];
651 var url = '../../main/calendar/add_edit_event.php?patientid=<?php echo urlencode($fs->pid); ?>';
652 if (f.ProviderID && f.ProviderID.value) {
653 url += '&userid=' + parseInt(f.ProviderID.value);
655 dlgopen(url, '_blank', 600, 300);
656 return false;
659 function warehouse_changed(sel) {
660 if (!confirm('<?php echo xls('Do you really want to change Warehouse?'); ?>')) {
661 // They clicked Cancel so reset selection to its default state.
662 for (var i = 0; i < sel.options.length; ++i) {
663 sel.options[i].selected = sel.options[i].defaultSelected;
668 // Invoked when a line item price level is changed.
669 function pricelevel_changed(sel) {
670 var f = document.forms[0];
671 var prname = sel.name.replace('pricelevel', 'price');
672 if (f[prname]) {
673 var price = parseFloat(sel.options[sel.selectedIndex].id.substring(4));
674 if (isNaN(price)) price = 0;
675 f[prname].value = price;
677 else {
678 alert('<?php echo xls('Form element not found'); ?>: ' + prname);
682 </script>
684 </head>
686 <body class="body_top">
687 <form method="post" action="<?php echo $rootdir; ?>/forms/fee_sheet/new.php?<?php
688 echo "rde=" . urlencode($rapid_data_entry) . "&addmore=" . urlencode($add_more_items); ?>"
689 onsubmit="return validate(this)">
690 <span class="title"><?php echo xlt('Fee Sheet'); ?></span><br>
691 <input type='hidden' name='newcodes' value=''>
693 <center>
695 <?php
696 $isBilled = !$add_more_items && isEncounterBilled($fs->pid, $fs->encounter);
697 if ($isBilled) {
698 echo "<p><font color='green'>" .
699 xlt("This encounter has been billed. To make changes, re-open it or select Add More Items.") .
700 "</font></p>\n";
702 else { // the encounter is not yet billed
705 <table width='95%'>
706 <?php
707 $i = 0;
708 $last_category = '';
710 // Create drop-lists based on the fee_sheet_options table.
711 $res = sqlStatement("SELECT * FROM fee_sheet_options " .
712 "ORDER BY fs_category, fs_option");
713 while ($row = sqlFetchArray($res)) {
714 $fs_category = $row['fs_category'];
715 $fs_option = $row['fs_option'];
716 $fs_codes = $row['fs_codes'];
717 if($fs_category !== $last_category) {
718 endFSCategory();
719 $last_category = $fs_category;
720 ++$i;
721 echo ($i <= 1) ? " <tr>\n" : "";
722 echo " <td width='50%' align='center' nowrap>\n";
723 echo " <select style='width:96%' onchange='codeselect(this)'>\n";
724 echo " <option value=''> " . xlt(substr($fs_category, 1)) . "</option>\n";
726 echo " <option value='" . attr($fs_codes) . "'>" . xlt(substr($fs_option, 1)) . "</option>\n";
728 endFSCategory();
730 // Create drop-lists based on categories defined within the codes.
731 $pres = sqlStatement("SELECT option_id, title FROM list_options " .
732 "WHERE list_id = 'superbill' AND activity = 1 ORDER BY seq");
733 while ($prow = sqlFetchArray($pres)) {
734 global $code_types;
735 ++$i;
736 echo ($i <= 1) ? " <tr>\n" : "";
737 echo " <td width='50%' align='center' nowrap>\n";
738 echo " <select style='width:96%' onchange='codeselect(this)'>\n";
739 echo " <option value=''> " . text(xl_list_label($prow['title'])) . "\n";
740 $res = sqlStatement("SELECT code_type, code, code_text,modifier FROM codes " .
741 "WHERE superbill = ? AND active = 1 " .
742 "ORDER BY code_text", array($prow['option_id']) );
743 while ($row = sqlFetchArray($res)) {
744 $ctkey = $fs->alphaCodeType($row['code_type']);
745 if ($code_types[$ctkey]['nofs']) continue;
746 echo " <option value='" . attr($ctkey) . "|" .
747 attr($row['code']) . ':'. attr($row['modifier']) . "|'>" . text($row['code_text']) . "</option>\n";
749 echo " </select>\n";
750 echo " </td>\n";
751 if ($i >= $FEE_SHEET_COLUMNS) {
752 echo " </tr>\n";
753 $i = 0;
757 // Create one more drop-list, for Products.
758 if ($GLOBALS['sell_non_drug_products']) {
759 ++$i;
760 echo ($i <= 1) ? " <tr>\n" : "";
761 echo " <td width='50%' align='center' nowrap>\n";
762 echo " <select name='Products' style='width:96%' onchange='codeselect(this)'>\n";
763 echo " <option value=''> " . xlt('Products') . "\n";
764 $tres = sqlStatement("SELECT dt.drug_id, dt.selector, d.name " .
765 "FROM drug_templates AS dt, drugs AS d WHERE " .
766 "d.drug_id = dt.drug_id AND d.active = 1 AND d.consumable = 0 " .
767 "ORDER BY d.name, dt.selector, dt.drug_id");
768 while ($trow = sqlFetchArray($tres)) {
769 echo " <option value='PROD|" . attr($trow['drug_id']) . '|' . attr($trow['selector']) . "'>";
770 echo text($trow['name']);
771 if ($trow['name'] !== $trow['selector']) echo ' / ' . text($trow['selector']);
772 echo "</option>\n";
774 echo " </select>\n";
775 echo " </td>\n";
776 if ($i >= $FEE_SHEET_COLUMNS) {
777 echo " </tr>\n";
778 $i = 0;
782 $search_type = $default_search_type;
783 if ($_POST['search_type']) $search_type = $_POST['search_type'];
785 $ndc_applies = true; // Assume all payers require NDC info.
787 echo $i ? " <td></td>\n </tr>\n" : "";
788 echo " <tr>\n";
789 echo " <td colspan='" . attr($FEE_SHEET_COLUMNS) . "' align='center' nowrap>\n";
791 // If Search was clicked, do it and write the list of results here.
792 // There's no limit on the number of results!
794 $numrows = 0;
795 if ($_POST['bn_search'] && $_POST['search_term']) {
796 $res = main_code_set_search($search_type,$_POST['search_term']);
797 if (!empty($res)) {
798 $numrows = sqlNumRows($res);
802 echo " <select name='Search Results' style='width:98%' " .
803 "onchange='codeselect(this)'";
804 if (! $numrows) echo ' disabled';
805 echo ">\n";
806 echo " <option value=''> " . xlt("Search Results") . " ($numrows " . xlt("items") . ")\n";
808 if ($numrows) {
809 while ($row = sqlFetchArray($res)) {
810 $code = $row['code'];
811 if ($row['modifier']) $code .= ":" . $row['modifier'];
812 echo " <option value='" . attr($search_type) . "|" . attr($code) . "|'>" . text($code) . " " .
813 text($row['code_text']) . "</option>\n";
817 echo " </select>\n";
818 echo " </td>\n";
819 echo " </tr>\n";
822 </table>
824 <p style='margin-top:8px;margin-bottom:8px'>
825 <table>
826 <tr>
827 <?php if ($fs->ALLOW_COPAYS) { ?>
828 <td>
829 <input type='button' value='<?php echo xla('Add Copay');?>'
830 onclick="copayselect()" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
831 </td>
832 <?php } ?>
833 <td>
834 <?php echo xlt('Search'); ?>&nbsp;
835 </td>
836 <td class='billcell'>
837 <?php
838 $nofs_code_types = array();
839 foreach ($code_types as $key => $value) {
840 if (!empty($value['nofs'])) continue;
841 $nofs_code_types[$key] = $value;
843 $size_select = (count($nofs_code_types) < 5) ? count($nofs_code_types) : 5;
845 <?php
846 foreach ($nofs_code_types as $key => $value) {
847 echo " <input type='radio' name='search_type' value='" . attr($key) . "'";
848 if ($key == $search_type) echo " checked";
849 echo " />" . xlt($value['label']) . "&nbsp;\n";
852 </td>
853 <td class='billcell'>
854 <?php echo xlt('for'); ?>&nbsp;
855 </td>
856 <td>
857 <input type='text' name='search_term' value=''> &nbsp;
858 </td>
859 <td>
860 <input type='submit' name='bn_search' value='<?php echo xla('Search');?>'
861 onclick='return this.clicked = true;'>
862 </td>
863 </tr>
864 </table>
865 </p>
866 <p style='margin-top:16px;margin-bottom:8px'>
868 <?php } // end encounter not billed ?>
870 <table cellspacing='5'>
871 <?php if ($billresult) { ?>
872 <tr>
873 <td class='billcell'><b><?php echo xlt('Type');?></b></td>
874 <td class='billcell'><b><?php echo xlt('Code');?></b></td>
875 <td class='billcell'><b><?php echo xlt('Description');?></b></td>
876 <?php if (modifiers_are_used(true)) { ?>
877 <td class='billcell'><b><?php echo xlt('Modifiers');?></b></td>
878 <?php } ?>
879 <?php if (fees_are_used()) { ?>
880 <?php if ($price_levels_are_used) { ?>
881 <td class='billcell' align='center'><b><?php echo xlt('Price Level');?></b>&nbsp;</td>
882 <?php } ?>
883 <td class='billcell' align='right'><b><?php echo xlt('Price');?></b>&nbsp;</td>
884 <td class='billcell' align='center'><b><?php echo xlt('Units');?></b></td>
885 <?php } ?>
886 <?php if (justifiers_are_used()) { ?>
887 <td class='billcell' align='center'<?php echo $justifystyle; ?>><b><?php echo xlt('Justify');?></b></td>
888 <?php } ?>
889 <td class='billcell' align='center' <?php echo $liprovstyle; ?>><b><?php echo xlt('Provider/Warehouse');?></b></td>
890 <td class='billcell' align='center'<?php echo $usbillstyle; ?>><b><?php echo xlt('Note Codes');?></b></td>
891 <td class='billcell' align='center'<?php echo $usbillstyle; ?>><b><?php echo xlt('Auth');?></b></td>
892 <?php if ($GLOBALS['gbl_auto_create_rx']) { ?>
893 <td class='billcell' align='center'><b><?php echo xlt('Rx'); ?></b></td>
894 <?php } ?>
895 <td class='billcell' align='center'><b><?php echo xlt('Delete');?></b></td>
896 </tr>
897 <?php } ?>
898 <?php
899 $justinit = "var f = document.forms[0];\n";
901 // Generate lines for items already in the billing table for this encounter,
902 // and also set the rendering provider if we come across one.
904 // $bill_lino = 0;
905 if ($billresult) {
906 foreach ($billresult as $iter) {
907 if (!$ALLOW_COPAYS && $iter["code_type"] == 'COPAY') continue;
908 if ($iter["code_type"] == 'TAX') continue;
909 // ++$bill_lino;
910 $bill_lino = count($fs->serviceitems);
911 $bline = $_POST['bill']["$bill_lino"];
912 $del = $bline['del']; // preserve Delete if checked
914 $modifier = trim($iter["modifier"]);
915 $units = $iter["units"];
916 $fee = $iter["fee"];
917 $authorized = $iter["authorized"];
918 $ndc_info = $iter["ndc_info"];
919 $justify = trim($iter['justify']);
920 $notecodes = trim($iter['notecodes']);
921 if ($justify) $justify = substr(str_replace(':', ',', $justify), 0, strlen($justify) - 1);
922 $provider_id = $iter['provider_id'];
924 // Also preserve other items from the form, if present.
925 if ($bline['id'] && !$iter["billed"]) {
926 $modifier = trim($bline['mod']);
927 $units = max(1, intval(trim($bline['units'])));
928 $fee = formatMoneyNumber((0 + trim($bline['price'])) * $units);
929 $authorized = $bline['auth'];
930 $ndc_info = '';
931 if ($bline['ndcnum']) {
932 $ndc_info = 'N4' . trim($bline['ndcnum']) . ' ' . $bline['ndcuom'] .
933 trim($bline['ndcqty']);
935 $justify = $bline['justify'];
936 $notecodes = trim($bline['notecodes']);
937 $provider_id = 0 + $bline['provid'];
940 if($iter['code_type'] == 'COPAY'){ // moved copay display to below
941 continue;
944 $fs->addServiceLineItem(array(
945 'codetype' => $iter['code_type'],
946 'code' => trim($iter['code']),
947 'modifier' => $modifier,
948 'ndc_info' => $ndc_info,
949 'auth' => $authorized,
950 'del' => $del,
951 'units' => $units,
952 'pricelevel' => $iter['pricelevel'],
953 'fee' => $fee,
954 'id' => $iter['id'],
955 'billed' => $iter['billed'],
956 'code_text' => trim($iter['code_text']),
957 'justify' => $justify,
958 'provider_id' => $provider_id,
959 'notecodes' => $notecodes,
964 $resMoneyGot = sqlStatement("SELECT pay_amount as PatientPay,session_id as id,date(post_time) as date ".
965 "FROM ar_activity where pid =? and encounter =? and payer_type=0 and account_code='PCP'",
966 array($fs->pid, $fs->encounter)); //new fees screen copay gives account_code='PCP'
967 while($rowMoneyGot = sqlFetchArray($resMoneyGot)){
968 $PatientPay=$rowMoneyGot['PatientPay']*-1;
969 $id=$rowMoneyGot['id'];
970 $fs->addServiceLineItem(array(
971 'codetype' => 'COPAY',
972 'code' => '',
973 'modifier' => '',
974 'ndc_info' => $rowMoneyGot['date'],
975 'auth' => 1,
976 'del' => '',
977 'units' => '',
978 'fee' => $PatientPay,
979 'id' => $id,
983 // Echo new billing items from this form here, but omit any line
984 // whose Delete checkbox is checked.
986 if ($_POST['bill']) {
987 foreach ($_POST['bill'] as $key => $iter) {
988 if ($iter["id"]) continue; // skip if it came from the database
989 if ($iter["del"]) continue; // skip if Delete was checked
990 $ndc_info = '';
991 if ($iter['ndcnum']) {
992 $ndc_info = 'N4' . trim($iter['ndcnum']) . ' ' . $iter['ndcuom'] .
993 trim($iter['ndcqty']);
995 $units = max(1, intval(trim($iter['units'])));
996 $fee = formatMoneyNumber((0 + trim($iter['price'])) * $units);
997 //the date is passed as $ndc_info, since this variable is not applicable in the case of copay.
998 $ndc_info = '';
999 if ($iter['code_type'] == 'COPAY'){
1000 $ndc_info = date("Y-m-d");
1001 if($fee > 0)
1002 $fee = 0 - $fee;
1004 $fs->addServiceLineItem(array(
1005 'codetype' => $iter['code_type'],
1006 'code' => trim($iter['code']),
1007 'modifier' => trim($iter["mod"]),
1008 'ndc_info' => $ndc_info,
1009 'auth' => $iter['auth'],
1010 'del' => $iter['del'],
1011 'units' => $units,
1012 'fee' => $fee,
1013 'justify' => $iter['justify'],
1014 'provider_id' => $iter['provid'],
1015 'notecodes' => $iter['notecodes'],
1016 'pricelevel' => $iter['pricelevel'],
1021 // Generate lines for items already in the drug_sales table for this encounter.
1023 $query = "SELECT ds.*, di.warehouse_id FROM drug_sales AS ds, drug_inventory AS di WHERE " .
1024 "ds.pid = ? AND ds.encounter = ? AND di.inventory_id = ds.inventory_id " .
1025 "ORDER BY sale_id";
1026 $sres = sqlStatement($query, array($fs->pid, $fs->encounter) );
1027 // $prod_lino = 0;
1028 while ($srow = sqlFetchArray($sres)) {
1029 // ++$prod_lino;
1030 $prod_lino = count($fs->productitems);
1031 $pline = $_POST['prod']["$prod_lino"];
1032 $rx = !empty($srow['prescription_id']);
1033 $del = $pline['del']; // preserve Delete if checked
1034 $sale_id = $srow['sale_id'];
1035 $drug_id = $srow['drug_id'];
1036 $selector = $srow['selector'];
1037 $pricelevel = $srow['pricelevel'];
1038 $units = $srow['quantity'];
1039 $fee = $srow['fee'];
1040 $billed = $srow['billed'];
1041 $warehouse_id = $srow['warehouse_id'];
1042 // Also preserve other items from the form, if present and unbilled.
1043 if ($pline['sale_id'] && !$srow['billed']) {
1044 $units = max(1, intval(trim($pline['units'])));
1045 $fee = formatMoneyNumber((0 + trim($pline['price'])) * $units);
1046 $rx = !empty($pline['rx']);
1048 $fs->addProductLineItem(array(
1049 'drug_id' => $drug_id,
1050 'selector' => $selector,
1051 'pricelevel' => $pricelevel,
1052 'rx' => $rx,
1053 'del' => $del,
1054 'units' => $units,
1055 'fee' => $fee,
1056 'sale_id' => $sale_id,
1057 'billed' => $billed,
1058 'warehouse_id' => $warehouse_id,
1062 // Echo new product items from this form here, but omit any line
1063 // whose Delete checkbox is checked.
1065 if ($_POST['prod']) {
1066 foreach ($_POST['prod'] as $key => $iter) {
1067 if ($iter["sale_id"]) continue; // skip if it came from the database
1068 if ($iter["del"]) continue; // skip if Delete was checked
1069 $units = max(1, intval(trim($iter['units'])));
1070 $fee = formatMoneyNumber((0 + trim($iter['price'])) * $units);
1071 $rx = !empty($iter['rx']); // preserve Rx if checked
1072 $warehouse_id = empty($iter['warehouse_id']) ? '' : $iter['warehouse_id'];
1073 $fs->addProductLineItem(array(
1074 'drug_id' => $iter['drug_id'],
1075 'selector' => $iter['selector'],
1076 'pricelevel' => $iter['pricelevel'],
1077 'rx' => $rx,
1078 'units' => $units,
1079 'fee' => $fee,
1080 'warehouse_id' => $warehouse_id,
1085 // If new billing code(s) were <select>ed, add their line(s) here.
1087 if ($_POST['newcodes'] && !$alertmsg) {
1088 $arrcodes = explode('~', $_POST['newcodes']);
1090 // A first pass here checks for any sex restriction errors.
1091 foreach ($arrcodes as $codestring) {
1092 if ($codestring === '') continue;
1093 list($newtype, $newcode) = explode('|', $codestring);
1094 if ($newtype == 'MA') {
1095 list($code, $modifier) = explode(":", $newcode);
1096 $tmp = sqlQuery("SELECT sex FROM codes WHERE code_type = ? AND code = ? LIMIT 1",
1097 array($code_types[$newtype]['id'], $code));
1098 if ($tmp['sex'] == '1' && $fs->patient_male || $tmp['sex'] == '2' && !$fs->patient_male) {
1099 $alertmsg = xl('Service is not compatible with the sex of this client.');
1104 if (!$alertmsg) foreach ($arrcodes as $codestring) {
1105 if ($codestring === '') continue;
1106 $arrcode = explode('|', $codestring);
1107 $newtype = $arrcode[0];
1108 $newcode = $arrcode[1];
1109 $newsel = $arrcode[2];
1110 if ($newtype == 'COPAY') {
1111 $tmp = sqlQuery("SELECT copay FROM insurance_data WHERE pid = ? " .
1112 "AND type = 'primary' ORDER BY date DESC LIMIT 1", array($fs->pid) );
1113 $code = formatMoneyNumber(0 + $tmp['copay']);
1114 $fs->addServiceLineItem(array(
1115 'codetype' => $newtype,
1116 'code' => $code,
1117 'ndc_info' => date('Y-m-d'),
1118 'auth' => '1',
1119 'units' => '1',
1120 'fee' => formatMoneyNumber(0 - $code),
1123 else if ($newtype == 'PROD') {
1124 $result = sqlQuery("SELECT dt.quantity, d.route " .
1125 "FROM drug_templates AS dt, drugs AS d WHERE " .
1126 "dt.drug_id = ? AND dt.selector = ? AND " .
1127 "d.drug_id = dt.drug_id",array($newcode,$newsel));
1128 $units = max(1, intval($result['quantity']));
1129 // By default create a prescription if drug route is set.
1130 $rx = !empty($result['route']);
1131 $fs->addProductLineItem(array(
1132 'drug_id' => $newcode,
1133 'selector' => $newsel,
1134 'rx' => $rx,
1135 'units' => $units,
1138 else {
1139 list($code, $modifier) = explode(":", $newcode);
1140 $ndc_info = '';
1141 // If HCPCS, find last NDC string used for this code.
1142 if ($newtype == 'HCPCS' && $ndc_applies) {
1143 $tmp = sqlQuery("SELECT ndc_info FROM billing WHERE " .
1144 "code_type = ? AND code = ? AND ndc_info LIKE 'N4%' " .
1145 "ORDER BY date DESC LIMIT 1", array($newtype,$code) );
1146 if (!empty($tmp)) $ndc_info = $tmp['ndc_info'];
1148 $fs->addServiceLineItem(array(
1149 'codetype' => $newtype,
1150 'code' => $code,
1151 'modifier' => trim($modifier),
1152 'ndc_info' => $ndc_info,
1158 // Write the form's line items.
1159 echoServiceLines();
1160 echoProductLines();
1163 </table>
1164 </p>
1166 <br />
1167 &nbsp;
1169 <?php
1170 // Choose rendering and supervising providers.
1171 echo "<span class='billcell'><b>\n";
1172 echo xlt('Providers') . ": &nbsp;";
1174 echo "&nbsp;&nbsp;" . xlt('Rendering') . "\n";
1175 echo $fs->genProviderSelect('ProviderID', '-- '.xl("Please Select").' --', $fs->provider_id, $isBilled);
1177 if (!$GLOBALS['ippf_specific']) {
1178 echo "&nbsp;&nbsp;" . xlt('Supervising') . "\n";
1179 echo $fs->genProviderSelect('SupervisorID', '-- '.xl("N/A").' --', $fs->supervisor_id, $isBilled);
1182 echo "<input type='button' value='" . xla('New Appointment') . "' onclick='newEvt()' />\n";
1184 echo "</b></span>\n";
1188 &nbsp;
1190 <?php
1191 if ($fs->contraception_code && !$isBilled) {
1192 // This will give the form save logic the associated contraceptive method.
1193 echo "<input type='hidden' name='ippfconmeth' value='" . attr($fs->contraception_code) . "'>\n";
1194 // If needed, this generates a dropdown to ask about prior contraception.
1195 echo $fs->generateContraceptionSelector();
1198 // Allow the patient price level to be fixed here.
1199 $plres = sqlStatement("SELECT option_id, title FROM list_options " .
1200 "WHERE list_id = 'pricelevel' AND activity = 1 ORDER BY seq, title");
1201 if (true) {
1202 $pricelevel = $fs->getPriceLevel();
1203 echo " <span class='billcell'><b>" . xlt('Default Price Level') . ":</b></span>\n";
1204 echo " <select name='pricelevel'";
1205 if ($isBilled) echo " disabled";
1206 echo ">\n";
1207 while ($plrow = sqlFetchArray($plres)) {
1208 $key = $plrow['option_id'];
1209 $val = $plrow['title'];
1210 echo " <option value='" . attr($key) . "'";
1211 if ($key == $pricelevel) echo ' selected';
1212 echo ">" . text(xl_list_label($val)) . "</option>\n";
1214 echo " </select>\n";
1218 &nbsp; &nbsp; &nbsp;
1220 <?php if (!$isBilled) { // visit is not yet billed ?>
1221 <input type='submit' name='bn_save' value='<?php echo xla('Save');?>'
1222 <?php if ($rapid_data_entry) echo " style='background-color:#cc0000';color:#ffffff'"; ?>
1224 <?php if ($GLOBALS['ippf_specific']) { // start ippf-only stuff ?>
1225 <?php if ($fs->hasCharges) { // unbilled with charges ?>
1226 <input type='submit' name='bn_save_close' value='<?php echo xla('Save and Checkout'); ?>' />
1227 <?php } else { // unbilled with no charges ?>
1228 <input type='submit' name='bn_save_close' value='<?php echo xla('Save and Close'); ?>' />
1229 <?php } // end no charges ?>
1230 &nbsp;
1231 <?php } // end ippf-only ?>
1232 <input type='submit' name='bn_refresh' onclick='return this.clicked = true;'
1233 value='<?php echo xla('Refresh');?>'>
1234 &nbsp;
1235 <?php } else { // visit is billed ?>
1236 <?php if ($fs->hasCharges) { // billed with charges ?>
1237 <input type='button' value='<?php echo xla('Show Receipt'); ?>'
1238 onclick="top.restoreSession();location='../../patient_file/pos_checkout.php?framed=1<?php
1239 echo "&ptid=" . urlencode($fs->pid) . "&enc=" . urlencode($fs->encounter); ?>'" />
1240 &nbsp;
1241 <input type='submit' name='bn_reopen' onclick='return this.clicked = 2;'
1242 value='<?php echo xla('Void Checkout and Re-Open'); ?>' />
1243 &nbsp;
1244 <?php } else { ?>
1245 <input type='submit' name='bn_reopen' onclick='return this.clicked = true;'
1246 value='<?php echo xla('Re-Open Visit'); ?>' />
1247 &nbsp;
1248 <?php } // end billed without charges ?>
1249 <input type='submit' name='bn_addmore' onclick='return this.clicked = true;'
1250 value='<?php echo xla('Add More Items'); ?>' />
1251 &nbsp;
1252 <?php } // end billed ?>
1253 <input type='hidden' name='form_has_charges' value='<?php echo $fs->hasCharges ? 1 : 0; ?>' />
1254 <input type='hidden' name='form_checksum' value='<?php echo $current_checksum; ?>' />
1255 <input type='hidden' name='form_alertmsg' value='<?php echo attr($alertmsg); ?>' />
1257 <input type='button' value='<?php echo xla('Cancel');?>'
1258 onclick="top.restoreSession();location='<?php echo $GLOBALS['form_exit_url']; ?>'" />
1260 </center>
1262 </form>
1264 <script language='JavaScript'>
1265 setSaveAndClose();
1267 <?php
1268 echo $justinit;
1269 if ($alertmsg) {
1270 echo "alert('" . addslashes($alertmsg) . "');\n";
1273 </script>
1275 </body>
1276 </html>
1277 <?php if (!empty($_POST['running_as_ajax'])) exit; ?>
1278 <?php require_once("review/initialize_review.php"); ?>
1279 <?php require_once("code_choice/initialize_code_choice.php"); ?>
1280 <?php if ($GLOBALS['ippf_specific']) require_once("contraception_products/initialize_contraception_products.php"); ?>
1281 <script>
1282 var translated_price_header="<?php echo xlt("Price");?>";
1283 </script>