6 * @link http://www.open-emr.org
7 * @author Rod Roark <rod@sunsetsystems.com>
8 * @author Brady Miller <brady.g.miller@gmail.com>
9 * @copyright Copyright (c) 2009-2017 Rod Roark <rod@sunsetsystems.com>
10 * @copyright Copyright (c) 2017 Brady Miller <brady.g.miller@gmail.com>
11 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
14 require_once("../../globals.php");
15 require_once("$srcdir/api.inc");
16 require_once("$srcdir/forms.inc");
17 require_once("$srcdir/options.inc.php");
18 require_once("$srcdir/patient.inc");
19 if ($GLOBALS['gbl_portal_cms_enable']) {
20 require_once("$include_root/cmsportal/portal.inc.php");
22 require_once($GLOBALS['fileroot'] . '/custom/code_types.inc.php');
23 require_once("$srcdir/FeeSheetHtml.class.php");
25 $CPR = 4; // cells per row
33 global $item_count, $cell_count, $historical_ids;
34 if ($item_count > 0) {
35 // echo " </td>";
38 foreach ($historical_ids as $key => $dummy) {
39 // $historical_ids[$key] .= " </td>";
40 $historical_ids[$key] .= "</td>";
49 global $cell_count, $CPR, $historical_ids;
51 if ($cell_count > 0) {
52 for (; $cell_count < $CPR; ++
$cell_count) {
54 foreach ($historical_ids as $key => $dummy) {
55 $historical_ids[$key] .= "<td></td>";
59 foreach ($historical_ids as $key => $dummy) {
60 echo $historical_ids[$key];
68 // $is_lbf is defined in trend_form.php and indicates that we are being
69 // invoked from there; in that case the current encounter is irrelevant.
70 $from_trend_form = !empty($is_lbf);
71 // Yet another invocation from somewhere other than encounter.
72 // don't show any action buttons.
73 $from_lbf_edit = isset($_GET['isShow']) ?
true : false;
74 // This is true if the page is loaded into an iframe in add_edit_issue.php.
75 $from_issue_form = !empty($_REQUEST['from_issue_form']);
77 $formname = isset($_GET['formname']) ?
$_GET['formname'] : '';
78 $formid = isset($_GET['id']) ?
intval($_GET['id']) : 0;
79 $portalid = isset($_GET['portalid']) ?
intval($_GET['portalid']) : 0;
81 $visitid = intval(empty($_GET['visitid']) ?
$encounter : $_GET['visitid']);
83 // If necessary get the encounter from the forms table entry for this form.
84 if ($formid && !$visitid) {
86 "SELECT pid, encounter FROM forms WHERE " .
87 "form_id = ? AND formdir = ? AND deleted = 0",
88 array($formid, $formname)
90 $visitid = intval($frow['encounter']);
91 if ($frow['pid'] != $pid) {
92 die("Internal error: patient ID mismatch!");
96 if (!$from_trend_form && !$visitid && !$from_lbf_edit) {
97 die("Internal error: we do not seem to be in an encounter!");
101 getLayoutProperties($formname, $grparr, '*');
103 $formtitle = $lobj['grp_title'];
104 $formhistory = 0 +
$lobj['grp_repeats'];
105 if (!empty($lobj['grp_columns' ])) {
106 $CPR = intval($lobj['grp_columns']);
108 if (!empty($lobj['grp_size' ])) {
109 $FONTSIZE = intval($lobj['grp_size']);
111 if (!empty($lobj['grp_issue_type'])) {
112 $LBF_ISSUE_TYPE = $lobj['grp_issue_type'];
114 if (!empty($lobj['grp_aco_spec' ])) {
115 $LBF_ACO = explode('|', $lobj['grp_aco_spec']);
117 if ($lobj['grp_services']) {
118 $LBF_SERVICES_SECTION = $lobj['grp_services'] == '*' ?
'' : $lobj['grp_services'];
120 if ($lobj['grp_products']) {
121 $LBF_PRODUCTS_SECTION = $lobj['grp_products'] == '*' ?
'' : $lobj['grp_products'];
123 if ($lobj['grp_diags' ]) {
124 $LBF_DIAGS_SECTION = $lobj['grp_diags' ] == '*' ?
'' : $lobj['grp_diags' ];
127 // Check access control.
128 if (!acl_check('admin', 'super') && !empty($LBF_ACO)) {
129 $auth_aco_write = acl_check($LBF_ACO[0], $LBF_ACO[1], '', 'write');
130 $auth_aco_addonly = acl_check($LBF_ACO[0], $LBF_ACO[1], '', 'addonly');
131 // echo "\n<!-- '$auth_aco_write' '$auth_aco_addonly' -->\n"; // debugging
132 if (!$auth_aco_write && !($auth_aco_addonly && !$formid)) {
133 die(xlt('Access denied'));
137 if (isset($LBF_SERVICES_SECTION) ||
isset($LBF_PRODUCTS_SECTION) ||
isset($LBF_DIAGS_SECTION)) {
138 $fs = new FeeSheetHtml($pid, $visitid);
141 if (!$from_trend_form) {
142 $fname = $GLOBALS['OE_SITE_DIR'] . "/LBF/$formname.plugin.php";
143 if (file_exists($fname)) {
144 include_once($fname);
148 // If Save was clicked, save the info.
150 if (!empty($_POST['bn_save']) ||
!empty($_POST['bn_save_print']) ||
!empty($_POST['bn_save_continue'])) {
153 // Creating a new form. Get the new form_id by inserting and deleting a dummy row.
154 // This is necessary to create the form instance even if it has no native data.
155 $newid = sqlInsert("INSERT INTO lbf_data " .
156 "( field_id, field_value ) VALUES ( '', '' )");
157 sqlStatement("DELETE FROM lbf_data WHERE form_id = ? AND " .
158 "field_id = ''", array($newid));
159 addForm($visitid, $formtitle, $newid, $formname, $pid, $userauthorized);
162 $my_form_id = $formid ?
$formid : $newid;
164 // If there is an issue ID, update it in the forms table entry.
165 if (isset($_POST['form_issue_id'])) {
167 "UPDATE forms SET issue_id = ? WHERE formdir = ? AND form_id = ? AND deleted = 0",
168 array($_POST['form_issue_id'], $formname, $my_form_id)
172 // If there is a provider ID, update it in the forms table entry.
173 if (isset($_POST['form_provider_id'])) {
175 "UPDATE forms SET provider_id = ? WHERE formdir = ? AND form_id = ? AND deleted = 0",
176 array($_POST['form_provider_id'], $formname, $my_form_id)
181 $fres = sqlStatement("SELECT * FROM layout_options " .
182 "WHERE form_id = ? AND uor > 0 AND field_id != '' AND " .
183 "edit_options != 'H' AND edit_options NOT LIKE '%0%' " .
184 "ORDER BY group_id, seq", array($formname));
185 while ($frow = sqlFetchArray($fres)) {
186 $field_id = $frow['field_id'];
187 $data_type = $frow['data_type'];
188 // If the field was not in the web form, skip it.
189 // Except if it's checkboxes, if unchecked they are not returned.
191 // if ($data_type != 21 && !isset($_POST["form_$field_id"])) continue;
193 // The above statement commented out 2015-01-12 because a LBF plugin might conditionally
194 // disable a field that is not applicable, and we need the ability to clear out the old
195 // garbage in there so it does not show up in the "report" view of the data. So we will
196 // trust that it's OK to clear any field that is defined in the layout but not returned
199 if ($data_type == 31) {
200 continue; // skip static text fields
202 $value = get_layout_form_value($frow);
203 // If edit option P or Q, save to the appropriate different table and skip the rest.
204 $source = $frow['source'];
205 if ($source == 'D' ||
$source == 'H') {
206 // Save to patient_data, employer_data or history_data.
207 if ($source == 'H') {
208 $new = array($field_id => $value);
209 updateHistoryData($pid, $new);
210 } else if (strpos($field_id, 'em_') === 0) {
211 $field_id = substr($field_id, 3);
212 $new = array($field_id => $value);
213 updateEmployerData($pid, $new);
215 $esc_field_id = escape_sql_column_name($field_id, array('patient_data'));
217 "UPDATE patient_data SET `$esc_field_id` = ? WHERE pid = ?",
223 } else if ($source == 'E') {
224 // Save to shared_attributes. Can't delete entries for empty fields because with the P option
225 // it's important to know when a current empty value overrides a previous value.
227 "REPLACE INTO shared_attributes SET " .
228 "pid = ?, encounter = ?, field_id = ?, last_update = NOW(), " .
229 "user_id = ?, field_value = ?",
230 array($pid, $visitid, $field_id, $_SESSION['authUserID'], $value)
233 } else if ($source == 'V') {
234 // Save to form_encounter.
235 $esc_field_id = escape_sql_column_name($field_id, array('form_encounter'));
237 "UPDATE form_encounter SET `$esc_field_id` = ? WHERE " .
238 "pid = ? AND encounter = ?",
239 array($value, $pid, $visitid)
244 // It's a normal form field, save to lbf_data.
245 if ($formid) { // existing form
247 $query = "DELETE FROM lbf_data WHERE " .
248 "form_id = ? AND field_id = ?";
249 sqlStatement($query, array($formid, $field_id));
251 $query = "REPLACE INTO lbf_data SET field_value = ?, " .
252 "form_id = ?, field_id = ?";
253 sqlStatement($query, array($value, $formid, $field_id));
258 "INSERT INTO lbf_data " .
259 "( form_id, field_id, field_value ) VALUES ( ?, ?, ? )",
260 array($newid, $field_id, $value)
267 // Delete the request from the portal.
268 $result = cms_portal_call(array('action' => 'delpost', 'postid' => $portalid));
269 if ($result['errmsg']) {
270 die(text($result['errmsg']));
275 $bill = is_array($_POST['form_fs_bill']) ?
$_POST['form_fs_bill'] : null;
276 $prod = is_array($_POST['form_fs_prod']) ?
$_POST['form_fs_prod'] : null;
277 $alertmsg = $fs->checkInventory($prod);
278 // If there is an inventory error then no services or products will be saved, and
279 // the form will be redisplayed with an error alert and everything else saved.
281 $fs->save($bill, $prod, null, null);
282 $fs->updatePriceLevel($_POST['form_fs_pricelevel']);
290 if (!$alertmsg && !$from_issue_form && empty($_POST['bn_save_continue'])) {
291 // Support custom behavior at save time, such as going to another form.
292 if (function_exists($formname . '_save_exit')) {
293 if (call_user_func($formname . '_save_exit')) {
297 formHeader("Redirecting....");
298 // If Save and Print, write the JavaScript to open a window for printing.
299 if (!empty($_POST['bn_save_print'])) {
300 echo "<script language='Javascript'>\n" .
301 "top.restoreSession();\n" .
302 "window.open('$rootdir/forms/LBF/printable.php?" .
303 "formname=" . urlencode($formname) .
304 "&formid=" . urlencode($formid) .
305 "&visitid=" . urlencode($visitid) .
306 "&patientid=" . urlencode($pid) .
319 <?php
html_header_show();?
>
320 <link rel
="stylesheet" href
="<?php echo $GLOBALS['assets_static_relative'] ?>/bootstrap-3-3-4/dist/css/bootstrap.min.css">
321 <?php
if ($_SESSION['language_direction'] == 'rtl') { ?
>
322 <link rel
="stylesheet" href
="<?php echo $GLOBALS['assets_static_relative'] ?>/bootstrap-rtl-3-3-4/dist/css/bootstrap-rtl.min.css">
324 <link rel
=stylesheet href
="<?php echo $css_header;?>" type
="text/css">
325 <link rel
="stylesheet" type
="text/css" href
="<?php echo $GLOBALS['webroot'] ?>/library/js/fancybox/jquery.fancybox-1.2.6.css" media
="screen" />
326 <link rel
="stylesheet" href
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.min.css">
330 td
, input
, select
, textarea
{
331 font
-family
: Arial
, Helvetica
, sans
-serif
;
335 .table
> tbody
> tr
> td
{
342 border
-color
: #0000ff;
355 border
-width
: 0 0 1px
0;
356 border
-color
: #999999;
361 border
-width
: 1px
1px
1px
1px
!important
;
362 border
-color
: #999999;
367 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/dialog.js?v=<?php echo $v_js_includes; ?>"></script
>
368 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-7-2/index.js"></script
>
369 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/js/common.js?v=<?php echo $v_js_includes; ?>"></script
>
370 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/js/fancybox/jquery.fancybox-1.2.6.js"></script
>
371 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery-ui.js"></script
>
372 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery.easydrag.handler.beta2.js"></script
>
373 <script type
="text/javascript" src
="../../../library/textformat.js?v=<?php echo $v_js_includes; ?>"></script
>
374 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.full.min.js"></script
>
376 <?php
include_once("{$GLOBALS['srcdir']}/options.js.php"); ?
>
378 <!-- LiterallyCanvas support
-->
379 <?php
echo lbf_canvas_head(); ?
>
381 <script language
="JavaScript">
383 // Support for beforeunload handler.
384 var somethingChanged
= false;
386 $
(document
).ready(function() {
389 if (window
.enable_modals
) {
395 if (window
.checkSkipConditions
) {
396 checkSkipConditions();
399 $
(".iframe_medium").fancybox({
400 'overlayOpacity' : 0.0,
401 'showCloseButton' : true,
406 // add drag and drop functionality to fancybox
407 $
("#fancy_outer").easydrag();
410 // Support for beforeunload handler.
411 $
('.lbfdata input, .lbfdata select, .lbfdata textarea').change(function() {
412 somethingChanged
= true;
414 window
.addEventListener("beforeunload", function (e
) {
415 if (somethingChanged
&& !top
.timed_out
) {
416 var msg
= "<?php echo xls('You have unsaved changes.'); ?>";
417 e
.returnValue
= msg
; // Gecko, Trident, Chrome 34+
418 return msg
; // Gecko, WebKit, Chrome <34
422 $
('.datepicker').datetimepicker({
423 <?php
$datetimepicker_timepicker = false; ?
>
424 <?php
$datetimepicker_showseconds = false; ?
>
425 <?php
$datetimepicker_formatInput = false; ?
>
426 <?php
require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?
>
427 <?php
// can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
429 $
('.datetimepicker').datetimepicker({
430 <?php
$datetimepicker_timepicker = true; ?
>
431 <?php
$datetimepicker_showseconds = false; ?
>
432 <?php
$datetimepicker_formatInput = false; ?
>
433 <?php
require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?
>
434 <?php
// can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
438 var mypcc
= '<?php echo $GLOBALS['phone_country_code
'] ?>';
440 // Supports customizable forms.
441 function divclick(cb
, divid
) {
442 var divstyle
= document
.getElementById(divid
).style
;
444 divstyle
.display
= 'block';
446 divstyle
.display
= 'none';
451 // The ID of the input element to receive a found code.
452 var current_sel_name
= '';
454 // This is for callback by the find-code popup.
455 // Appends to or erases the current list of related codes.
456 function set_related(codetype
, code
, selector
, codedesc
) {
457 var f
= document
.forms
[0];
458 <?php
if (isset($fs)) { ?
>
459 // This is the case of selecting a code for the Fee Sheet:
460 if (!current_sel_name
) {
462 $
.getScript('<?php echo $GLOBALS['web_root
'] ?>/library/ajax/code_attributes_ajax.php' +
463 '?codetype=' +
encodeURIComponent(codetype
) +
464 '&code=' +
encodeURIComponent(code
) +
465 '&selector=' +
encodeURIComponent(selector
) +
466 '&pricelevel=' +
encodeURIComponent(f
.form_fs_pricelevel ? f
.form_fs_pricelevel
.value
: ""));
471 // frc will be the input element containing the codes.
472 // frcd, if set, will be the input element containing their descriptions.
473 var frc
= f
[current_sel_name
];
475 var matches
= current_sel_name
.match(/^
(.*)__desc$
/);
480 // For LBFs we will allow only one code in a field.
481 var s
= ''; // frc.value;
482 var sd
= ''; // frcd ? frcd.value : s;
488 s +
= codetype +
':' + code
;
495 if (frcd
) frcd
.value
= sd
;
499 // This invokes the "dynamic" find-code popup.
500 function sel_related(elem
, codetype
) {
501 current_sel_name
= elem ? elem
.name
: '';
502 var url
= '<?php echo $rootdir ?>/patient_file/encounter/find_code_dynamic.php';
503 if (codetype
) url +
= '?codetype=' + codetype
;
504 dlgopen(url
, '_blank', 800, 500);
507 // Compute the length of a string without leading and trailing spaces.
508 function trimlen(s
) {
510 var j
= s
.length
- 1;
511 for (; i
<= j
&& s
.charAt(i
) == ' '; ++i
);
512 for (; i
<= j
&& s
.charAt(j
) == ' '; --j
);
517 // This capitalizes the first letter of each word in the passed input
518 // element. It also strips out extraneous spaces.
519 function capitalizeMe(elem
) {
520 var a
= elem
.value
.split(' ');
522 for(var i
= 0; i
< a
.length
; ++i
) {
523 if (a
[i
].length
> 0) {
524 if (s
.length
> 0) s +
= ' ';
525 s +
= a
[i
].charAt(0).toUpperCase() + a
[i
].substring(1);
531 // Validation logic for form submission.
532 function validate(f
) {
533 <?php
generate_layout_validation($formname); ?
>
534 // Validation for Fee Sheet stuff. Skipping this because CV decided (2015-11-03)
535 // that these warning messages are not appropriate for layout based visit forms.
537 // if (window.jsLineItemValidation && !jsLineItemValidation(f)) return false;
538 somethingChanged
= false; // turn off "are you sure you want to leave"
539 top
.restoreSession();
545 // jsLineItemValidation() function for the fee sheet stuff.
546 echo $fs->jsLineItemValidation('form_fs_bill', 'form_fs_prod');
549 // Add a service line item.
550 function fs_append_service(code_type
, code
, desc
, price
) {
551 var telem
= document
.getElementById('fs_services_table');
552 var lino
= telem
.rows
.length
- 1;
553 var trelem
= telem
.insertRow(telem
.rows
.length
);
555 "<td class='text'>" + code +
" </td>" +
556 "<td class='text'>" + desc +
" </td>" +
557 "<td class='text'>" +
558 "<select name='form_fs_bill[" + lino +
"][provid]'>" +
559 "<?php echo addslashes($fs->genProviderOptionList('-- ' . xl('Default') . ' --')) ?>" +
562 "<td class='text' align='right'>" + price +
" </td>" +
563 "<td class='text' align='right'>" +
564 "<input type='checkbox' name='form_fs_bill[" + lino +
"][del]' value='1' />" +
565 "<input type='hidden' name='form_fs_bill[" + lino +
"][code_type]' value='" + code_type +
"' />" +
566 "<input type='hidden' name='form_fs_bill[" + lino +
"][code]' value='" + code +
"' />" +
567 "<input type='hidden' name='form_fs_bill[" + lino +
"][price]' value='" + price +
"' />" +
571 // Add a product line item.
572 function fs_append_product(code_type
, code
, desc
, price
, warehouses
) {
573 var telem
= document
.getElementById('fs_products_table');
575 alert('<?php echo xla('A product was selected but there is no product section in this form
.'); ?>');
578 var lino
= telem
.rows
.length
- 1;
579 var trelem
= telem
.insertRow(telem
.rows
.length
);
581 "<td class='text'>" + desc +
" </td>" +
582 "<td class='text'>" +
583 "<select name='form_fs_prod[" + lino +
"][warehouse]'>" + warehouses +
"</select> " +
585 "<td class='text' align='right'>" +
586 "<input type='text' name='form_fs_prod[" + lino +
"][units]' size='3' value='1' /> " +
588 "<td class='text' align='right'>" + price +
" </td>" +
589 "<td class='text' align='right'>" +
590 "<input type='checkbox' name='form_fs_prod[" + lino +
"][del]' value='1' />" +
591 "<input type='hidden' name='form_fs_prod[" + lino +
"][drug_id]' value='" + code +
"' />" +
592 "<input type='hidden' name='form_fs_prod[" + lino +
"][price]' value='" + price +
"' />" +
596 // Add a diagnosis line item.
597 function fs_append_diag(code_type
, code
, desc
) {
598 var telem
= document
.getElementById('fs_diags_table');
599 // Adding 1000 because form_fs_bill[] is shared with services and we want to avoid collisions.
600 var lino
= telem
.rows
.length
- 1 +
1000;
601 var trelem
= telem
.insertRow(telem
.rows
.length
);
603 "<td class='text'>" + code +
" </td>" +
604 "<td class='text'>" + desc +
" </td>" +
605 "<td class='text' align='right'>" +
606 "<input type='checkbox' name='form_fs_bill[" + lino +
"][del]' value='1' />" +
607 "<input type='hidden' name='form_fs_bill[" + lino +
"][code_type]' value='" + code_type +
"' />" +
608 "<input type='hidden' name='form_fs_bill[" + lino +
"][code]' value='" + code +
"' />" +
609 "<input type='hidden' name='form_fs_bill[" + lino +
"][price]' value='" +
0 +
"' />" +
613 // Respond to clicking a checkbox for adding (or removing) a specific service.
614 function fs_service_clicked(cb
) {
616 // The checkbox value is a JSON array containing the service's code type, code, description,
617 // and price for each price level.
618 var a
= JSON
.parse(cb
.value
);
620 // The checkbox was UNchecked.
621 // Find last row with a matching code_type and code and set its del flag.
622 var telem
= document
.getElementById('fs_services_table');
623 var lino
= telem
.rows
.length
- 2;
624 for (; lino
>= 0; --lino
) {
625 var pfx
= "form_fs_bill[" + lino +
"]";
626 if (f
[pfx +
"[code_type]"].value
== a
[0] && f
[pfx +
"[code]"].value
== a
[1]) {
627 f
[pfx +
"[del]"].checked
= true;
633 $
.getScript('<?php echo $GLOBALS['web_root
'] ?>/library/ajax/code_attributes_ajax.php' +
634 '?codetype=' +
encodeURIComponent(a
[0]) +
635 '&code=' +
encodeURIComponent(a
[1]) +
636 '&pricelevel=' +
encodeURIComponent(f
.form_fs_pricelevel
.value
));
639 // Respond to clicking a checkbox for adding (or removing) a specific product.
640 function fs_product_clicked(cb
) {
642 // The checkbox value is a JSON array containing the product's code type, code and selector.
643 var a
= JSON
.parse(cb
.value
);
645 // The checkbox was UNchecked.
646 // Find last row with a matching product ID and set its del flag.
647 var telem
= document
.getElementById('fs_products_table');
648 var lino
= telem
.rows
.length
- 2;
649 for (; lino
>= 0; --lino
) {
650 var pfx
= "form_fs_prod[" + lino +
"]";
651 if (f
[pfx +
"[code_type]"].value
== a
[0] && f
[pfx +
"[code]"].value
== a
[1]) {
652 f
[pfx +
"[del]"].checked
= true;
658 $
.getScript('<?php echo $GLOBALS['web_root
'] ?>/library/ajax/code_attributes_ajax.php' +
659 '?codetype=' +
encodeURIComponent(a
[0]) +
660 '&code=' +
encodeURIComponent(a
[1]) +
661 '&selector=' +
encodeURIComponent(a
[2]) +
662 '&pricelevel=' +
encodeURIComponent(f
.form_fs_pricelevel
.value
));
665 // Respond to clicking a checkbox for adding (or removing) a specific diagnosis.
666 function fs_diag_clicked(cb
) {
668 // The checkbox value is a JSON array containing the diagnosis's code type, code, description.
669 var a
= JSON
.parse(cb
.value
);
671 // The checkbox was UNchecked.
672 // Find last row with a matching code_type and code and set its del flag.
673 var telem
= document
.getElementById('fs_diags_table');
674 var lino
= telem
.rows
.length
- 2 +
1000;
675 for (; lino
>= 0; --lino
) {
676 var pfx
= "form_fs_bill[" + lino +
"]";
677 if (f
[pfx +
"[code_type]"].value
== a
[0] && f
[pfx +
"[code]"].value
== a
[1]) {
678 f
[pfx +
"[del]"].checked
= true;
684 $
.getScript('<?php echo $GLOBALS['web_root
'] ?>/library/ajax/code_attributes_ajax.php' +
685 '?codetype=' +
encodeURIComponent(a
[0]) +
686 '&code=' +
encodeURIComponent(a
[1]) +
687 '&pricelevel=' +
encodeURIComponent(f
.form_fs_pricelevel ? f
.form_fs_pricelevel
.value
: ""));
690 // Respond to selecting a package of codes.
691 function fs_package_selected(sel
) {
693 // The option value is an encoded string of code types and codes.
695 $
.getScript('<?php echo $GLOBALS['web_root
'] ?>/library/ajax/code_attributes_ajax.php' +
696 '?list=' +
encodeURIComponent(sel
.value
) +
697 '&pricelevel=' +
encodeURIComponent(f
.form_fs_pricelevel ? f
.form_fs_pricelevel
.value
: ""));
699 sel
.selectedIndex
= 0;
702 // This is called back by code_attributes_ajax.php to complete the appending of a line item.
703 function code_attributes_handler(codetype
, code
, desc
, price
, warehouses
) {
704 if (codetype
== 'PROD') {
705 fs_append_product(codetype
, code
, desc
, price
, warehouses
);
707 else if (codetype
== 'ICD9' || codetype
== 'ICD10') {
708 fs_append_diag(codetype
, code
, desc
);
711 fs_append_service(codetype
, code
, desc
, price
);
715 function warehouse_changed(sel
) {
716 if (!confirm('<?php echo xls('Do you really want to change Warehouse?
'); ?>')) {
717 // They clicked Cancel so reset selection to its default state.
718 for (var i
= 0; i
< sel
.options
.length
; ++i
) {
719 sel
.options
[i
].selected
= sel
.options
[i
].defaultSelected
;
724 <?php
} // end if (isset($fs))
726 if (function_exists($formname . '_javascript')) {
727 call_user_func($formname . '_javascript');
734 <body
class="body_top"<?php
if ($from_issue_form) {
735 echo " style='background-color:#ffffff'";} ?
>>
736 <div
class='container'>
738 echo "<form method='post' " .
739 "action='$rootdir/forms/LBF/new.php?formname=$formname&id=$formid&portalid=$portalid' " .
740 "onsubmit='return validate(this)'>\n";
742 $cmsportal_login = '';
749 if (!$from_trend_form) {
750 $enrow = sqlQuery("SELECT p.fname, p.mname, p.lname, p.cmsportal_login, " .
752 "form_encounter AS fe, forms AS f, patient_data AS p WHERE " .
753 "p.pid = ? AND f.pid = p.pid AND f.encounter = ? AND " .
754 "f.formdir = 'newpatient' AND f.deleted = 0 AND " .
755 "fe.id = f.form_id LIMIT 1", array($pid, $visitid)); ?
>
757 <div
class="container-responsive">
759 <div
class="col-xs-12">
760 <div
class="page-header">
762 <?php
echo text($formtitle) . " " . xlt('for') . ' ';
763 echo text($enrow['fname']) . ' ' . text($enrow['mname']) . ' ' . text($enrow['lname']);
764 echo ' ' . xlt('on') . ' ' . text(oeFormatShortDate(substr($enrow['date'], 0, 10))); ?
>
768 "SELECT issue_id, provider_id FROM forms WHERE " .
769 "formdir = ? AND form_id = ? AND deleted = 0",
770 array($formname, $formid)
772 $form_issue_id = empty($firow['issue_id']) ?
0 : intval($firow['issue_id']);
773 $form_provider_id = empty($firow['provider_id']) ?
0 : intval($firow['provider_id']);
775 // Provider selector.
777 echo xlt('Provider') . ": ";
778 // TBD: Refactor this function out of the FeeSheetHTML class as that is not the best place for it.
779 echo FeeSheetHtml
::genProviderSelect('form_provider_id', '-- ' . xl("Please Select") . ' --', $form_provider_id);
781 // If appropriate build a drop-down selector of issues of this type for this patient.
782 // We skip this if in an issue form tab because removing and adding visit form tabs is
783 // beyond the current scope of that code.
784 if (!empty($LBF_ISSUE_TYPE) && !$from_issue_form) {
786 $query = "SELECT id, title, date, begdate FROM lists WHERE pid = ? AND type = ? " .
787 "ORDER BY COALESCE(begdate, date) DESC, id DESC";
788 $ires = sqlStatement($query, array($pid, $LBF_ISSUE_TYPE));
789 echo "<select name='form_issue_id'>\n";
790 echo " <option value='0'>-- " . xlt('Select Case') . " --</option>\n";
791 while ($irow = sqlFetchArray($ires)) {
792 $issueid = $irow['id'];
793 $issuedate = oeFormatShortDate(empty($irow['begdate']) ?
$irow['date'] : $irow['begdate']);
794 echo " <option value='" . attr($issueid) . "'";
795 if ($issueid == $form_issue_id) {
798 echo ">" . text("$issuedate " . $irow['title']) . "</option>\n";
806 <?php
$cmsportal_login = $enrow['cmsportal_login'];
807 } // end not from trend form
809 // If loading data from portal, get the data.
810 if ($GLOBALS['gbl_portal_cms_enable'] && $portalid) {
811 $portalres = cms_portal_call(array('action' => 'getpost', 'postid' => $portalid));
812 if ($portalres['errmsg']) {
813 die(text($portalres['errmsg']));
818 <!-- This is where a chart might display
. -->
819 <div id
="chart"></div
>
822 $shrow = getHistoryData($pid);
824 // Determine if this layout uses edit option "I" anywhere.
825 // If not we default to only the first group being initially open.
826 $tmprow = sqlQuery("SELECT form_id FROM layout_options " .
827 "WHERE form_id = ? AND uor > 0 AND edit_options LIKE '%I%' " .
828 "LIMIT 1", array($formname));
829 $some_group_is_open = !empty($tmprow['form_id']);
831 $fres = sqlStatement("SELECT * FROM layout_options " .
832 "WHERE form_id = ? AND uor > 0 " .
833 "ORDER BY group_id, seq", array($formname));
836 $display_style = 'block';
838 // This string is the active group levels. Each leading substring represents an instance of nesting.
841 // This indicates if </table> will need to be written to end the fields in a group.
842 $group_table_active = false;
844 // This is an array keyed on forms.form_id for other occurrences of this
845 // form type. The maximum number of such other occurrences to display is
846 // in list_options.option_value for this form's list item. Values in this
847 // array are work areas for building the ending HTML for each displayed row.
849 $historical_ids = array();
851 // True if any data items in this form can be graphed.
852 $form_is_graphable = false;
856 while ($frow = sqlFetchArray($fres)) {
857 $this_group = $frow['group_id'];
858 $titlecols = $frow['titlecols'];
859 $datacols = $frow['datacols'];
860 $data_type = $frow['data_type'];
861 $field_id = $frow['field_id'];
862 $list_id = $frow['list_id'];
863 $edit_options = $frow['edit_options'];
864 $source = $frow['source'];
866 $graphable = isOption($edit_options, 'G') !== false;
868 $form_is_graphable = true;
871 // Accumulate action conditions into a JSON expression for the browser side.
872 accumActionConditions($field_id, $condition_str, $frow['conditions']);
876 if (isOption($edit_options, 'H') !== false) {
877 // This data comes from static history
878 if (isset($shrow[$field_id])) {
879 $currvalue = $shrow[$field_id];
882 if (!$formid && $portalres) {
883 // Copying CMS Portal form data into this field if appropriate.
884 $currvalue = cms_field_to_lbf($data_type, $field_id, $portalres['fields']);
887 if ($currvalue === '') {
888 $currvalue = lbf_current_value($frow, $formid, $is_lbf ?
0 : $encounter);
891 if ($currvalue === false) {
892 continue; // column does not exist, should not happen
895 // Handle "P" edit option to default to the previous value of a form field.
896 if (!$from_trend_form && empty($currvalue) && isOption($edit_options, 'P') !== false) {
897 if ($source == 'F' && !$formid) {
898 // Form attribute for new form, get value from most recent form instance.
899 // Form attributes of existing forms are expected to have existing values.
901 "SELECT encounter, form_id FROM forms WHERE " .
902 "pid = ? AND formdir = ? AND deleted = 0 " .
903 "ORDER BY date DESC LIMIT 1",
904 array($pid, $formname)
906 if (!empty($tmp['encounter'])) {
907 $currvalue = lbf_current_value($frow, $tmp['form_id'], $tmp['encounter']);
909 } else if ($source == 'E') {
910 // Visit attribute, get most recent value as of this visit.
911 // Even if the form already exists for this visit it may have a readonly value that only
912 // exists in a previous visit and was created from a different form.
914 "SELECT sa.field_value FROM form_encounter AS e1 " .
915 "JOIN form_encounter AS e2 ON " .
916 "e2.pid = e1.pid AND (e2.date < e1.date OR (e2.date = e1.date AND e2.encounter <= e1.encounter)) " .
917 "JOIN shared_attributes AS sa ON " .
918 "sa.pid = e2.pid AND sa.encounter = e2.encounter AND sa.field_id = ?" .
919 "WHERE e1.pid = ? AND e1.encounter = ? " .
920 "ORDER BY e2.date DESC, e2.encounter DESC LIMIT 1",
921 array($field_id, $pid, $visitid)
923 if (isset($tmp['field_value'])) {
924 $currvalue = $tmp['field_value'];
927 } // End "P" option logic.
930 $this_levels = $this_group;
932 $mincount = min(strlen($this_levels), strlen($group_levels));
933 while ($i < $mincount && $this_levels[$i] == $group_levels[$i]) {
936 // $i is now the number of initial matching levels.
938 // If ending a group or starting a subgroup, terminate the current row and its table.
939 if ($group_table_active && ($i != strlen($group_levels) ||
$i != strlen($this_levels))) {
942 $group_table_active = false;
945 // Close any groups that we are done with.
946 while (strlen($group_levels) > $i) {
947 $gname = $grparr[$group_levels]['grp_title'];
948 $group_levels = substr($group_levels, 0, -1); // remove last character
949 // No div for an empty group name.
950 if (strlen($gname)) {
955 // If there are any new groups, open them.
956 while ($i < strlen($this_levels)) {
958 if ($group_table_active) {
960 $group_table_active = false;
962 $group_levels .= $this_levels[$i++
];
963 $gname = $grparr[substr($group_levels, 0, $i)]['grp_title'];
964 $subtitle = $grparr[substr($group_levels, 0, $i)]['grp_subtitle'];
965 // Compute a short unique identifier for this group.
966 $group_seq = 'lbf' . $group_levels;
967 $group_name = $gname;
969 if ($some_group_is_open) {
970 // Must have edit option "I" in first item for its group to be initially open.
971 $display_style = isOption($edit_options, 'I') === false ?
'none' : 'block';
974 // If group name is blank, no checkbox or div.
975 if (strlen($gname)) {
976 echo "<br /><span class='bold'><input type='checkbox' name='form_cb_" . attr($group_seq) . "' value='1' " .
977 "onclick='return divclick(this,\"div_" . attr(addslashes($group_seq)) . "\");'";
978 if ($display_style == 'block') {
982 echo " /><b>" . text(xl_layout_label($group_name)) . "</b></span>\n";
983 echo "<div id='div_" . attr($group_seq) . "' class='section table-responsive' style='display:" . attr($display_style) . ";'>\n";
986 $group_table_active = true;
987 echo " <table border='0' cellspacing='0' cellpadding='0' class='lbfdata'>\n";
990 // There is a group subtitle so show it.
991 echo "<tr><td class='bold' style='color:#0000ff' colspan='" . attr($CPR) . "'>" . text($subtitle) . "</td></tr>\n";
992 echo "<tr><td class='bold' style='height:4pt' colspan='" . attr($CPR) . "'></td></tr>\n";
995 $display_style = 'none';
997 // Initialize historical data array and write date headers.
998 $historical_ids = array();
999 if ($formhistory > 0) {
1001 echo "<td colspan='" . attr($CPR) . "' align='right' class='bold'>";
1002 if (empty($is_lbf)) {
1003 // Including actual date per IPPF request 2012-08-23.
1004 echo oeFormatShortDate(substr($enrow['date'], 0, 10));
1005 echo ' (' . htmlspecialchars(xl('Current')) . ')';
1008 echo " </td>\n";
1009 $hres = sqlStatement(
1010 "SELECT f.form_id, fe.date " .
1011 "FROM forms AS f, form_encounter AS fe WHERE " .
1012 "f.pid = ? AND f.formdir = ? AND " .
1013 "f.form_id != ? AND f.deleted = 0 AND " .
1014 "fe.pid = f.pid AND fe.encounter = f.encounter " .
1015 "ORDER BY fe.date DESC, f.encounter DESC, f.date DESC " .
1017 array($pid, $formname, $formid, $formhistory)
1019 // For some readings like vitals there may be multiple forms per encounter.
1020 // We sort these sensibly, however only the encounter date is shown here;
1021 // at some point we may wish to show also the data entry date/time.
1022 while ($hrow = sqlFetchArray($hres)) {
1023 echo "<td colspan='" . attr($CPR) . "' align='right' class='bold'> " .
1024 text(oeFormatShortDate(substr($hrow['date'], 0, 10))) . "</td>\n";
1025 $historical_ids[$hrow['form_id']] = '';
1032 // Handle starting of a new row.
1033 if (($titlecols > 0 && $cell_count >= $CPR) ||
$cell_count == 0) {
1035 if (isOption($edit_options, 'RS')) {
1036 echo " <tr class='RS'>";
1037 } else if (isOption($edit_options, 'RO')) {
1038 echo " <tr class='RO'>";
1043 // Clear historical data string.
1044 foreach ($historical_ids as $key => $dummy) {
1045 $historical_ids[$key] = '';
1049 if ($item_count == 0 && $titlecols == 0) {
1053 // First item is on the "left-border"
1056 // Handle starting of a new label cell.
1057 if ($titlecols > 0) {
1059 if (isOption($edit_options, 'SP')) {
1062 echo "<td valign='top' colspan='" . attr($titlecols) . "'";
1064 echo "<td valign='top' colspan='" . attr($titlecols) . "' nowrap";
1067 echo ($frow['uor'] == 2) ?
"required" : "bold";
1074 if ($cell_count > 0) {
1075 echo " style='padding-left:10pt'";
1077 // This ID is used by action conditions and also show_graph().
1078 echo " id='label_id_" . attr($field_id) . "'";
1081 foreach ($historical_ids as $key => $dummy) {
1082 $historical_ids[$key] .= "<td valign='top' colspan='" . attr($titlecols) . "' class='text' nowrap>";
1085 $cell_count +
= $titlecols;
1091 if ($frow['title']) {
1092 $tmp = xl_layout_label($frow['title']);
1094 // Append colon only if label does not end with punctuation.
1095 if (strpos('?!.,:-=', substr($tmp, -1, 1)) === false) {
1103 // Note the labels are not repeated in the history columns.
1105 // Handle starting of a new data cell.
1106 if ($datacols > 0) {
1108 if (isOption($edit_options, 'DS')) {
1109 echo "<td valign='top' colspan='" . attr($datacols) . "' class='text RS'";
1111 if (isOption($edit_options, 'DO')) {
1112 echo "<td valign='top' colspan='" . attr($datacols) . "' class='text RO'";
1114 echo "<td valign='top' colspan='" . attr($datacols) . "' class='text'";
1116 // This ID is used by action conditions.
1117 echo " id='value_id_" . attr($field_id) . "'";
1118 if ($cell_count > 0) {
1119 echo " style='padding-left:5pt'";
1124 foreach ($historical_ids as $key => $dummy) {
1125 $historical_ids[$key] .= "<td valign='top' align='right' colspan='" . attr($datacols) . "' class='text'>";
1128 $cell_count +
= $datacols;
1133 // Skip current-value fields for the display-only case.
1134 if (!$from_trend_form) {
1135 if ($frow['edit_options'] == 'H') {
1136 echo generate_display_field($frow, $currvalue);
1138 generate_form_field($frow, $currvalue);
1142 // Append to historical data of other dates for this item.
1143 foreach ($historical_ids as $key => $dummy) {
1144 $value = lbf_current_value($frow, $key, 0);
1145 $historical_ids[$key] .= generate_display_field($frow, $value);
1149 // Close all open groups.
1150 if ($group_table_active) {
1153 $group_table_active = false;
1155 while (strlen($group_levels)) {
1156 $gname = $grparr[$group_levels]['grp_title'];
1157 $group_levels = substr($group_levels, 0, -1); // remove last character
1158 // No div for an empty group name.
1159 if (strlen($gname)) {
1164 $display_style = 'none';
1166 if (isset($LBF_SERVICES_SECTION) ||
isset($LBF_DIAGS_SECTION)) {
1167 $fs->loadServiceItems();
1170 if (isset($LBF_SERVICES_SECTION)) {
1171 // Create the checkbox and div for the Services Section.
1172 echo "<br /><span class='bold'><input type='checkbox' name='form_cb_fs_services' value='1' " .
1173 "onclick='return divclick(this, \"div_fs_services\");'";
1174 if ($display_style == 'block') {
1177 echo " /><b>" . xlt('Services') . "</b></span>\n";
1178 echo "<div id='div_fs_services' class='section' style='display:" . attr($display_style) . ";'>\n";
1180 $display_style = 'none';
1182 // If there are associated codes, generate a checkbox for each one.
1183 if ($LBF_SERVICES_SECTION) {
1184 echo "<table cellpadding='0' cellspacing='0' width='100%'>\n";
1186 $tdpct = (int) (100 / $cols);
1188 $relcodes = explode(';', $LBF_SERVICES_SECTION);
1189 foreach ($relcodes as $codestring) {
1190 if ($codestring === '') {
1193 $codes_esc = htmlspecialchars($codestring, ENT_QUOTES
);
1194 $cbval = $fs->genCodeSelectorValue($codestring);
1195 if ($count %
$cols == 0) {
1201 echo " <td width='" . attr($tdpct) . "%'>";
1202 echo "<input type='checkbox' id='form_fs_services[$codes_esc]' " .
1203 "onclick='fs_service_clicked(this)' value='" . attr($cbval) . "'";
1204 if ($fs->code_is_in_fee_sheet
) {
1207 list($codetype, $code) = explode(':', $codestring);
1208 $title = lookup_code_descriptions($codestring);
1209 $title = empty($title) ?
$code : xl_list_label($title);
1210 echo " />" . htmlspecialchars($title, ENT_NOQUOTES
);
1220 // A row for Search, Add Package, Main Provider.
1221 $ctype = $GLOBALS['ippf_specific'] ?
'MA' : '';
1222 echo "<p class='bold'>";
1223 echo "<input type='button' value='" . xla('Search Services') . "' onclick='sel_related(null,\"$ctype\")' /> \n";
1224 $fscres = sqlStatement("SELECT * FROM fee_sheet_options ORDER BY fs_category, fs_option");
1225 if (sqlNumRows($fscres)) {
1226 $last_category = '';
1227 echo "<select onchange='fs_package_selected(this)'>\n";
1228 echo " <option value=''>" . xlt('Add Package') . "</option>\n";
1229 while ($row = sqlFetchArray($fscres)) {
1230 $fs_category = $row['fs_category'];
1231 $fs_option = $row['fs_option'];
1232 $fs_codes = $row['fs_codes'];
1233 if ($fs_category !== $last_category) {
1234 if ($last_category) {
1235 echo " </optgroup>\n";
1237 echo " <optgroup label='" . xla(substr($fs_category, 1)) . "'>\n";
1238 $last_category = $fs_category;
1240 echo " <option value='" . attr($fs_codes) . "'>" . xlt(substr($fs_option, 1)) . "</option>\n";
1242 if ($last_category) {
1243 echo " </optgroup>\n";
1245 echo "</select> \n";
1247 echo xlt('Main Provider') . ": ";
1248 echo $fs->genProviderSelect("form_fs_provid", ' ', $fs->provider_id
);
1252 // Generate a line for each service already in this FS.
1253 echo "<table cellpadding='0' cellspacing='2' id='fs_services_table'>\n";
1255 echo " <td class='bold' colspan='2'>" . xlt('Services Provided') . " </td>\n";
1256 echo " <td class='bold'>" . xlt('Provider') . " </td>\n";
1257 echo " <td class='bold' align='right'>" . xlt('Price') . " </td>\n";
1258 echo " <td class='bold' align='right'>" . xlt('Delete') . "</td>\n";
1260 foreach ($fs->serviceitems
as $lino => $li) {
1261 // Skip diagnoses; those would be in the Diagnoses section below.
1262 if ($code_types[$li['codetype']]['diag']) {
1266 echo " <td class='text'>" . text($li['code']) . " </td>\n";
1267 echo " <td class='text'>" . text($li['code_text']) . " </td>\n";
1268 echo " <td class='text'>" .
1269 $fs->genProviderSelect("form_fs_bill[$lino][provid]", '-- ' . xl("Default") . ' --', $li['provid']) .
1271 echo " <td class='text' align='right'>" . oeFormatMoney($li['price']) . " </td>\n";
1272 echo " <td class='text' align='right'>\n" .
1273 " <input type='checkbox' name='form_fs_bill[$lino][del]' " .
1274 "value='1'" . ($li['del'] ?
" checked" : "") . " />\n";
1275 foreach ($li['hidden'] as $hname => $hvalue) {
1276 echo " <input type='hidden' name='form_fs_bill[$lino][" . attr($hname) . "]' value='" . attr($hvalue) . "' />\n";
1284 } // End Services Section
1286 if (isset($LBF_PRODUCTS_SECTION)) {
1287 // Create the checkbox and div for the Products Section.
1288 echo "<br /><span class='bold'><input type='checkbox' name='form_cb_fs_products' value='1' " .
1289 "onclick='return divclick(this, \"div_fs_products\");'";
1290 if ($display_style == 'block') {
1293 echo " /><b>" . xlt('Products') . "</b></span>\n";
1294 echo "<div id='div_fs_products' class='section' style='display:" . attr($display_style) . ";'>\n";
1296 $display_style = 'none';
1298 // If there are associated codes, generate a checkbox for each one.
1299 if ($LBF_PRODUCTS_SECTION) {
1300 echo "<table cellpadding='0' cellspacing='0' width='100%'>\n";
1302 $tdpct = (int) (100 / $cols);
1304 $relcodes = explode(';', $LBF_PRODUCTS_SECTION);
1305 foreach ($relcodes as $codestring) {
1306 if ($codestring === '') {
1309 $codes_esc = htmlspecialchars($codestring, ENT_QUOTES
);
1310 $cbval = $fs->genCodeSelectorValue($codestring);
1311 if ($count %
$cols == 0) {
1317 echo " <td width='" . attr($tdpct) . "%'>";
1318 echo "<input type='checkbox' id='form_fs_products[$codes_esc]' " .
1319 "onclick='fs_product_clicked(this)' value='" . attr($cbval) . "'";
1320 if ($fs->code_is_in_fee_sheet
) {
1323 list($codetype, $code) = explode(':', $codestring);
1325 "SELECT name FROM drugs WHERE " .
1326 "drug_id = ? ORDER BY drug_id LIMIT 1",
1329 $title = empty($crow['name']) ?
$code : xl_list_label($crow['name']);
1330 echo " />" . htmlspecialchars($title, ENT_NOQUOTES
);
1341 $ctype = $GLOBALS['ippf_specific'] ?
'MA' : '';
1342 echo "<p class='bold'>";
1343 echo "<input type='button' value='" . xla('Search Products') . "' onclick='sel_related(null,\"PROD\")' /> ";
1346 // Generate a line for each product already in this FS.
1347 echo "<table cellpadding='0' cellspacing='2' id='fs_products_table'>\n";
1349 echo " <td class='bold'>" . xlt('Products Provided') . " </td>\n";
1350 echo " <td class='bold'>" . xlt('Warehouse') . " </td>\n";
1351 echo " <td class='bold' align='right'>" . xlt('Quantity') . " </td>\n";
1352 echo " <td class='bold' align='right'>" . xlt('Price') . " </td>\n";
1353 echo " <td class='bold' align='right'>" . xlt('Delete') . "</td>\n";
1355 $fs->loadProductItems();
1356 foreach ($fs->productitems
as $lino => $li) {
1358 echo " <td class='text'>" . text($li['code_text']) . " </td>\n";
1359 echo " <td class='text'>" .
1360 $fs->genWarehouseSelect("form_fs_prod[$lino][warehouse]", '', $li['warehouse'], false, $li['hidden']['drug_id'], true) .
1362 echo " <td class='text' align='right'>" .
1363 "<input type='text' name='form_fs_prod[$lino][units]' size='3' value='" . $li['units'] . "' />" .
1365 echo " <td class='text' align='right'>" . oeFormatMoney($li['price']) . " </td>\n";
1366 echo " <td class='text' align='right'>\n" .
1367 " <input type='checkbox' name='form_fs_prod[$lino][del]' " .
1368 "value='1'" . ($li['del'] ?
" checked" : "") . " />\n";
1369 foreach ($li['hidden'] as $hname => $hvalue) {
1370 echo " <input type='hidden' name='form_fs_prod[$lino][" . attr($hname) . "]' value='" . attr($hvalue) . "' />\n";
1378 } // End Products Section
1380 if (isset($LBF_DIAGS_SECTION)) {
1381 // Create the checkbox and div for the Diagnoses Section.
1382 echo "<br /><span class='bold'><input type='checkbox' name='form_cb_fs_diags' value='1' " .
1383 "onclick='return divclick(this, \"div_fs_diags\");'";
1384 if ($display_style == 'block') {
1387 echo " /><b>" . xlt('Diagnoses') . "</b></span>\n";
1388 echo "<div id='div_fs_diags' class='section' style='display:" . attr($display_style) . ";'>\n";
1390 $display_style = 'none';
1392 // If there are associated codes, generate a checkbox for each one.
1393 if ($LBF_DIAGS_SECTION) {
1394 echo "<table cellpadding='0' cellspacing='0' width='100%'>\n";
1396 $tdpct = (int) (100 / $cols);
1398 $relcodes = explode(';', $LBF_DIAGS_SECTION);
1399 foreach ($relcodes as $codestring) {
1400 if ($codestring === '') {
1403 $codes_esc = htmlspecialchars($codestring, ENT_QUOTES
);
1404 $cbval = $fs->genCodeSelectorValue($codestring);
1405 if ($count %
$cols == 0) {
1411 echo " <td width='" . attr($tdpct) . "%'>";
1412 echo "<input type='checkbox' id='form_fs_diags[$codes_esc]' " .
1413 "onclick='fs_diag_clicked(this)' value='" . attr($cbval) . "'";
1414 if ($fs->code_is_in_fee_sheet
) {
1417 list($codetype, $code) = explode(':', $codestring);
1418 $title = lookup_code_descriptions($codestring);
1419 $title = empty($title) ?
$code : xl_list_label($title);
1420 echo " />" . htmlspecialchars($title, ENT_NOQUOTES
);
1430 // A row for Search.
1431 $ctype = collect_codetypes('diagnosis', 'csv');
1432 echo "<p class='bold'>";
1433 echo "<input type='button' value='" . xla('Search Diagnoses') . "' onclick='sel_related(null,\"$ctype\")' />";
1436 // Generate a line for each diagnosis already in this FS.
1437 echo "<table cellpadding='0' cellspacing='2' id='fs_diags_table'>\n";
1439 echo " <td class='bold' colspan='2'>" . xlt('Diagnosis') . " </td>\n";
1440 echo " <td class='bold' align='right'>" . xlt('Delete') . "</td>\n";
1442 foreach ($fs->serviceitems
as $lino => $li) {
1443 // Skip anything that is not a diagnosis; those are in the Services section above.
1444 if (!$code_types[$li['codetype']]['diag']) {
1448 echo " <td class='text'>" . text($li['code']) . " </td>\n";
1449 echo " <td class='text'>" . text($li['code_text']) . " </td>\n";
1450 // The Diagnoses section shares the form_fs_bill array with the Services section.
1451 echo " <td class='text' align='right'>\n" .
1452 " <input type='checkbox' name='form_fs_bill[$lino][del]' " .
1453 "value='1'" . ($li['del'] ?
" checked" : "") . " />\n";
1454 foreach ($li['hidden'] as $hname => $hvalue) {
1455 echo " <input type='hidden' name='form_fs_bill[$lino][" . attr($hname) . "]' value='" . attr($hvalue) . "' />\n";
1463 } // End Diagnoses Section
1468 <div
class="col-xs-12">
1469 <div
class="btn-group">
1472 if (!$from_trend_form && !$from_lbf_edit) {
1473 // Generate price level selector if we are doing services or products.
1474 if (isset($LBF_SERVICES_SECTION) ||
isset($LBF_PRODUCTS_SECTION)) {
1475 echo xlt('Price Level') . ": ";
1476 echo $fs->generatePriceLevelSelector('form_fs_pricelevel');
1477 echo " ";
1480 <button type
="submit" class="btn btn-default btn-save" name
="bn_save" value
="<?php echo xla('Save'); ?>">
1481 <?php
echo xlt('Save'); ?
>
1485 <button type
='submit' class="btn btn-link" name
='bn_save_continue' value
='<?php echo xla('Save
and Continue') ?>'>
1486 <?php
echo xlt('Save and Continue'); ?
>
1489 if (!$from_issue_form) {
1492 <button type
='submit' class="btn btn-link" name
='bn_save_print' value
='<?php echo xla('Save
and Print') ?>'>
1493 <?php
echo xlt('Save and Print'); ?
>
1496 if (function_exists($formname . '_additional_buttons')) {
1497 // Allow the plug-in to insert more action buttons here.
1498 call_user_func($formname . '_additional_buttons');
1501 if ($form_is_graphable) {
1503 <button type
='button' class="btn btn-default btn-graph" onclick
="top.restoreSession();location='../../patient_file/encounter/trend_form.php?formname=<?php echo attr($formname); ?>'">
1504 <?php
echo xlt('Show Graph') ?
>
1508 } // end form is graphable
1510 <button type
='button' class="btn btn-link btn-cancel" onclick
="top.restoreSession();location='<?php echo $GLOBALS['form_exit_url']; ?>'">
1511 <?php
echo xlt('Cancel'); ?
>
1514 } // end not from issue form
1517 } elseif (!$from_lbf_edit) { // $from_trend_form is true but lbf edit doesn't want button
1519 <button type
='button' class="btn btn-default btn-back" onclick
='window.history.back();'>
1520 <?php
echo xlt('Back') ?
>
1523 } // end from trend form
1528 <?php
if (!$from_trend_form) { // end row and container divs ?>
1533 <input type
='hidden' name
='from_issue_form' value
='<?php echo text($from_issue_form); ?>' />
1537 <!-- include support
for the
list-add selectbox feature
-->
1538 <?php
include $GLOBALS['fileroot'] . "/library/options_listadd.inc"; ?
>
1540 <script language
="JavaScript">
1542 // Array of action conditions for the checkSkipConditions() function.
1544 <?php
echo $condition_str; ?
>
1547 <?php
echo $date_init; ?
>
1549 if (function_exists($formname . '_javascript_onload')) {
1550 call_user_func($formname . '_javascript_onload');
1553 // New form and this patient has a portal login and we have not loaded portal data.
1554 // Check if there is portal data pending for this patient and form type.
1555 if (!$alertmsg && !$formid && $GLOBALS['gbl_portal_cms_enable'] && $cmsportal_login && !$portalid) {
1556 $portalres = cms_portal_call(array('action' => 'checkptform', 'form' => $formname, 'patient' => $cmsportal_login));
1557 if ($portalres['errmsg']) {
1558 die(text($portalres['errmsg'])); // TBD: Change to alertmsg
1561 $portalid = $portalres['postid'];
1563 echo "if (confirm('" . xls('The portal has data for this patient and form. Load it now?') . "')) {\n";
1564 echo " top.restoreSession();\n";
1565 echo " document.location.href = 'load_form.php?formname=$formname&portalid=$portalid';\n";
1571 echo "alert('" . addslashes($alertmsg) . "');\n";