migrated ubiquitous libraries to composer autoloader (#421)
[openemr.git] / interface / forms / LBF / new.php
blobac82482d4c0219cdcba6595e54d7ea78eefa2494
1 <?php
2 /**
3 * Copyright (C) 2009-2016 Rod Roark <rod@sunsetsystems.com>
5 * LICENSE: This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>.
16 * @package OpenEMR
17 * @author Rod Roark <rod@sunsetsystems.com>
18 * @link http://www.open-emr.org
21 //SANITIZE ALL ESCAPES
22 $sanitize_all_escapes=true;
24 //STOP FAKE REGISTER GLOBALS
25 $fake_register_globals=false;
27 require_once("../../globals.php");
28 require_once("$srcdir/api.inc");
29 require_once("$srcdir/forms.inc");
30 require_once("$srcdir/options.inc.php");
31 require_once("$srcdir/patient.inc");
32 require_once("$srcdir/formatting.inc.php");
33 if ($GLOBALS['gbl_portal_cms_enable']) {
34 require_once("$include_root/cmsportal/portal.inc.php");
37 $CPR = 4; // cells per row
39 $pprow = array();
41 // $is_lbf is defined in trend_form.php and indicates that we are being
42 // invoked from there; in that case the current encounter is irrelevant.
43 if (empty($is_lbf) && !$encounter) {
44 die("Internal error: we do not seem to be in an encounter!");
47 function end_cell() {
48 global $item_count, $cell_count, $historical_ids;
49 if ($item_count > 0) {
50 // echo "&nbsp;</td>";
51 echo "</td>";
53 foreach ($historical_ids as $key => $dummy) {
54 // $historical_ids[$key] .= "&nbsp;</td>";
55 $historical_ids[$key] .= "</td>";
58 $item_count = 0;
62 function end_row() {
63 global $cell_count, $CPR, $historical_ids;
64 end_cell();
65 if ($cell_count > 0) {
66 for (; $cell_count < $CPR; ++$cell_count) {
67 echo "<td></td>";
68 foreach ($historical_ids as $key => $dummy) {
69 $historical_ids[$key] .= "<td></td>";
73 foreach ($historical_ids as $key => $dummy) {
74 echo $historical_ids[$key];
77 echo "</tr>\n";
78 $cell_count = 0;
82 function end_group() {
83 global $last_group;
84 if (strlen($last_group) > 0) {
85 end_row();
86 echo " </table>\n";
87 // No div for an empty group name.
88 if (strlen($last_group) > 1) {
89 echo "</div>\n"; // div after checkbox
90 echo "</div>\n"; // outer div, including checkbox
95 $formname = isset($_GET['formname']) ? $_GET['formname'] : '';
96 $formid = isset($_GET['id'] ) ? intval($_GET['id']) : 0;
97 $portalid = isset($_GET['portalid']) ? intval($_GET['portalid']) : 0;
99 // Get some info about this form.
100 $tmp = sqlQuery("SELECT title, option_value, notes FROM list_options WHERE " .
101 "list_id = 'lbfnames' AND option_id = ? AND activity = 1", array($formname));
102 $formtitle = $tmp['title'];
103 $formhistory = 0 + $tmp['option_value'];
105 if (empty($is_lbf)) {
106 $fname = $GLOBALS['OE_SITE_DIR'] . "/LBF/$formname.plugin.php";
107 if (file_exists($fname)) include_once($fname);
110 // If Save was clicked, save the info.
112 if ($_POST['bn_save']) {
113 $newid = 0;
114 if (!$formid) {
115 // Creating a new form. Get the new form_id by inserting and deleting a dummy row.
116 // This is necessary to create the form instance even if it has no native data.
117 $newid = sqlInsert("INSERT INTO lbf_data " .
118 "( field_id, field_value ) VALUES ( '', '' )");
119 sqlStatement("DELETE FROM lbf_data WHERE form_id = ? AND " .
120 "field_id = ''", array($newid));
121 addForm($encounter, $formtitle, $newid, $formname, $pid, $userauthorized);
123 $sets = "";
124 $fres = sqlStatement("SELECT * FROM layout_options " .
125 "WHERE form_id = ? AND uor > 0 AND field_id != '' AND " .
126 "edit_options != 'H' AND edit_options NOT LIKE '%0%' " .
127 "ORDER BY group_name, seq", array($formname) );
128 while ($frow = sqlFetchArray($fres)) {
129 $field_id = $frow['field_id'];
130 $data_type = $frow['data_type'];
131 // If the field was not in the web form, skip it.
132 // Except if it's checkboxes, if unchecked they are not returned.
134 // if ($data_type != 21 && !isset($_POST["form_$field_id"])) continue;
136 // The above statement commented out 2015-01-12 because a LBF plugin might conditionally
137 // disable a field that is not applicable, and we need the ability to clear out the old
138 // garbage in there so it does not show up in the "report" view of the data. So we will
139 // trust that it's OK to clear any field that is defined in the layout but not returned
140 // by the form.
142 $value = get_layout_form_value($frow);
143 // If edit option P or Q, save to the appropriate different table and skip the rest.
144 $source = $frow['source'];
145 if ($source == 'D' || $source == 'H') {
146 // Save to patient_data, employer_data or history_data.
147 if ($source == 'H') {
148 $new = array($field_id => $value);
149 updateHistoryData($pid, $new);
151 else if (strpos($field_id, 'em_') === 0) {
152 $field_id = substr($field_id, 3);
153 $new = array($field_id => $value);
154 updateEmployerData($pid, $new);
156 else {
157 $esc_field_id = escape_sql_column_name($field_id, array('patient_data'));
158 sqlStatement("UPDATE patient_data SET `$esc_field_id` = ? WHERE pid = ?",
159 array($value, $pid));
161 continue;
163 else if ($source == 'E') {
164 // Save to shared_attributes. Can't delete entries for empty fields because with the P option
165 // it's important to know when a current empty value overrides a previous value.
166 sqlStatement("REPLACE INTO shared_attributes SET " .
167 "pid = ?, encounter = ?, field_id = ?, last_update = NOW(), " .
168 "user_id = ?, field_value = ?",
169 array($pid, $encounter, $field_id, $_SESSION['authUserID'], $value));
170 continue;
172 else if ($source == 'V') {
173 // Save to form_encounter.
174 $esc_field_id = escape_sql_column_name($field_id, array('form_encounter'));
175 sqlStatement("UPDATE form_encounter SET `$esc_field_id` = ? WHERE " .
176 "pid = ? AND encounter = ?",
177 array($value, $pid, $encounter));
178 continue;
180 // It's a normal form field, save to lbf_data.
181 if ($formid) { // existing form
182 if ($value === '') {
183 $query = "DELETE FROM lbf_data WHERE " .
184 "form_id = ? AND field_id = ?";
185 sqlStatement($query, array($formid, $field_id));
187 else {
188 $query = "REPLACE INTO lbf_data SET field_value = ?, " .
189 "form_id = ?, field_id = ?";
190 sqlStatement($query,array($value, $formid, $field_id));
193 else { // new form
194 if ($value !== '') {
195 sqlStatement("INSERT INTO lbf_data " .
196 "( form_id, field_id, field_value ) VALUES ( ?, ?, ? )",
197 array($newid, $field_id, $value));
202 if ($portalid) {
203 // Delete the request from the portal.
204 $result = cms_portal_call(array('action' => 'delpost', 'postid' => $portalid));
205 if ($result['errmsg']) {
206 die(text($result['errmsg']));
210 // Support custom behavior at save time, such as going to another form.
211 if (function_exists($formname . '_save_exit')) {
212 if (call_user_func($formname . '_save_exit')) exit;
214 formHeader("Redirecting....");
215 formJump();
216 formFooter();
217 exit;
221 <html>
222 <head>
223 <?php html_header_show();?>
224 <link rel=stylesheet href="<?php echo $css_header;?>" type="text/css">
225 <style>
227 td, input, select, textarea {
228 font-family: Arial, Helvetica, sans-serif;
229 font-size: 10pt;
232 div.section {
233 border: solid;
234 border-width: 1px;
235 border-color: #0000ff;
236 margin: 0 0 0 10pt;
237 padding: 5pt;
240 </style>
242 <style type="text/css">@import url(../../../library/dynarch_calendar.css);</style>
244 <link rel="stylesheet" type="text/css" href="<?php echo $GLOBALS['webroot'] ?>/library/js/fancybox/jquery.fancybox-1.2.6.css" media="screen" />
245 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/dialog.js?v=<?php echo $v_js_includes; ?>"></script>
246 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-3-2/index.js"></script>
247 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/js/common.js"></script>
248 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/js/fancybox/jquery.fancybox-1.2.6.js"></script>
249 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery-ui.js"></script>
250 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery.easydrag.handler.beta2.js"></script>
251 <script type="text/javascript" src="../../../library/textformat.js"></script>
252 <script type="text/javascript" src="../../../library/dynarch_calendar.js"></script>
253 <?php include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?>
254 <script type="text/javascript" src="../../../library/dynarch_calendar_setup.js"></script>
255 <?php include_once("{$GLOBALS['srcdir']}/options.js.php"); ?>
257 <!-- LiterallyCanvas support -->
258 <?php echo lbf_canvas_head(); ?>
260 <script language="JavaScript">
262 // Support for beforeunload handler.
263 var somethingChanged = false;
265 $(document).ready(function() {
267 // fancy box
268 if (window.enable_modals) {
269 enable_modals();
271 if(window.tabbify){
272 tabbify();
274 if (window.checkSkipConditions) {
275 checkSkipConditions();
277 // special size for
278 $(".iframe_medium").fancybox({
279 'overlayOpacity' : 0.0,
280 'showCloseButton' : true,
281 'frameHeight' : 580,
282 'frameWidth' : 900
284 $(function() {
285 // add drag and drop functionality to fancybox
286 $("#fancy_outer").easydrag();
289 // Support for beforeunload handler.
290 $('.lbfdata input, .lbfdata select, .lbfdata textarea').change(function() {
291 somethingChanged = true;
293 window.addEventListener("beforeunload", function (e) {
294 if (somethingChanged && !top.timed_out) {
295 var msg = "<?php echo xls('You have unsaved changes.'); ?>";
296 e.returnValue = msg; // Gecko, Trident, Chrome 34+
297 return msg; // Gecko, WebKit, Chrome <34
303 var mypcc = '<?php echo $GLOBALS['phone_country_code'] ?>';
305 // Supports customizable forms.
306 function divclick(cb, divid) {
307 var divstyle = document.getElementById(divid).style;
308 if (cb.checked) {
309 divstyle.display = 'block';
310 } else {
311 divstyle.display = 'none';
313 return true;
316 // The ID of the input element to receive a found code.
317 var current_sel_name = '';
319 // This is for callback by the find-code popup.
320 // Appends to or erases the current list of related codes.
321 function set_related(codetype, code, selector, codedesc) {
322 var f = document.forms[0];
323 // frc will be the input element containing the codes.
324 // frcd, if set, will be the input element containing their descriptions.
325 var frc = f[current_sel_name];
326 var frcd;
327 var matches = current_sel_name.match(/^(.*)__desc$/);
328 if (matches) {
329 frcd = frc;
330 frc = f[matches[1]];
332 var s = frc.value;
333 var sd = frcd ? frcd.value : s;
334 if (code) {
335 if (codetype != 'PROD') {
336 if (s.indexOf(codetype + ':') == 0 || s.indexOf(';' + codetype + ':') > 0) {
337 return '<?php echo xl('A code of this type is already selected. Erase the field first if you need to replace it.') ?>';
340 if (s.length > 0) {
341 s += ';';
342 sd += ';';
344 s += codetype + ':' + code;
345 sd += codedesc;
346 } else {
347 s = '';
348 sd = '';
350 frc.value = s;
351 if (frcd) frcd.value = sd;
352 return '';
355 // This invokes the find-code popup.
356 function sel_related(elem, codetype) {
357 current_sel_name = elem.name;
358 var url = '<?php echo $rootdir ?>/patient_file/encounter/find_code_popup.php';
359 if (codetype) url += '?codetype=' + codetype;
360 dlgopen(url, '_blank', 500, 400);
363 // Compute the length of a string without leading and trailing spaces.
364 function trimlen(s) {
365 var i = 0;
366 var j = s.length - 1;
367 for (; i <= j && s.charAt(i) == ' '; ++i);
368 for (; i <= j && s.charAt(j) == ' '; --j);
369 if (i > j) return 0;
370 return j + 1 - i;
373 // Validation logic for form submission.
374 function validate(f) {
375 <?php generate_layout_validation($formname); ?>
376 somethingChanged = false; // turn off "are you sure you want to leave"
377 top.restoreSession();
378 return true;
381 <?php if (function_exists($formname . '_javascript')) call_user_func($formname . '_javascript'); ?>
383 </script>
384 </head>
386 <body <?php echo $top_bg_line; ?> topmargin="0" rightmargin="0" leftmargin="2" bottommargin="0" marginwidth="2" marginheight="0">
388 <?php
389 echo "<form method='post' " .
390 "action='$rootdir/forms/LBF/new.php?formname=$formname&id=$formid&portalid=$portalid' " .
391 "onsubmit='return validate(this)'>\n";
393 $cmsportal_login = '';
394 $portalres = FALSE;
395 if (empty($is_lbf)) {
396 $enrow = sqlQuery("SELECT p.fname, p.mname, p.lname, p.cmsportal_login, " .
397 "fe.date FROM " .
398 "form_encounter AS fe, forms AS f, patient_data AS p WHERE " .
399 "p.pid = ? AND f.pid = p.pid AND f.encounter = ? AND " .
400 "f.formdir = 'newpatient' AND f.deleted = 0 AND " .
401 "fe.id = f.form_id LIMIT 1", array($pid, $encounter));
402 echo "<p class='title' style='margin-top:8px;margin-bottom:8px;text-align:center'>\n";
403 echo text($formtitle) . " " . xlt('for') . ' ';
404 echo text($enrow['fname']) . ' ' . text($enrow['mname']) . ' ' . text($enrow['lname']);
405 echo ' ' . xlt('on') . ' ' . text(oeFormatShortDate(substr($enrow['date'], 0, 10)));
406 echo "</p>\n";
407 $cmsportal_login = $enrow['cmsportal_login'];
409 // If loading data from portal, get the data.
410 if ($GLOBALS['gbl_portal_cms_enable'] && $portalid) {
411 $portalres = cms_portal_call(array('action' => 'getpost', 'postid' => $portalid));
412 if ($portalres['errmsg']) {
413 die(text($portalres['errmsg']));
418 <!-- This is where a chart might display. -->
419 <div id="chart"></div>
421 <?php
422 $shrow = getHistoryData($pid);
424 $fres = sqlStatement("SELECT * FROM layout_options " .
425 "WHERE form_id = ? AND uor > 0 " .
426 "ORDER BY group_name, seq", array($formname) );
427 $last_group = '';
428 $cell_count = 0;
429 $item_count = 0;
430 $display_style = 'block';
432 // This is an array keyed on forms.form_id for other occurrences of this
433 // form type. The maximum number of such other occurrences to display is
434 // in list_options.option_value for this form's list item. Values in this
435 // array are work areas for building the ending HTML for each displayed row.
437 $historical_ids = array();
439 // True if any data items in this form can be graphed.
440 $form_is_graphable = false;
442 $condition_str = '';
444 while ($frow = sqlFetchArray($fres)) {
445 $this_group = $frow['group_name'];
446 $titlecols = $frow['titlecols'];
447 $datacols = $frow['datacols'];
448 $data_type = $frow['data_type'];
449 $field_id = $frow['field_id'];
450 $list_id = $frow['list_id'];
451 $edit_options = $frow['edit_options'];
452 $source = $frow['source'];
454 $graphable = strpos($edit_options, 'G') !== FALSE;
455 if ($graphable) $form_is_graphable = true;
457 // Accumulate skip conditions into a JavaScript string literal.
458 $conditions = empty($frow['conditions']) ? array() : unserialize($frow['conditions']);
459 foreach ($conditions as $condition) {
460 if (empty($condition['id'])) continue;
461 $andor = empty($condition['andor']) ? '' : $condition['andor'];
462 if ($condition_str) $condition_str .= ",\n";
463 $condition_str .= "{" .
464 "target:'" . addslashes($field_id) . "', " .
465 "id:'" . addslashes($condition['id']) . "', " .
466 "itemid:'" . addslashes($condition['itemid']) . "', " .
467 "operator:'" . addslashes($condition['operator']) . "', " .
468 "value:'" . addslashes($condition['value']) . "', " .
469 "andor:'" . addslashes($andor) . "'}";
472 $currvalue = '';
474 if ($frow['edit_options'] == 'H') {
475 // This data comes from static history
476 if (isset($shrow[$field_id])) $currvalue = $shrow[$field_id];
477 } else {
478 if (!$formid && $portalres) {
479 // Copying CMS Portal form data into this field if appropriate.
480 $currvalue = cms_field_to_lbf($data_type, $field_id, $portalres['fields']);
482 if ($currvalue === '') {
483 $currvalue = lbf_current_value($frow, $formid, $is_lbf ? 0 : $encounter);
485 if ($currvalue === FALSE) continue; // column does not exist, should not happen
486 // Handle "P" edit option to default to the previous value of a form field.
487 if (!$is_lbf && empty($currvalue) && strpos($edit_options, 'P') !== FALSE) {
488 if ($source == 'F' && !$formid) {
489 // Form attribute for new form, get value from most recent form instance.
490 // Form attributes of existing forms are expected to have existing values.
491 $tmp = sqlQuery("SELECT encounter, form_id FROM forms WHERE " .
492 "pid = ? AND formdir = ? AND deleted = 0 " .
493 "ORDER BY date DESC LIMIT 1",
494 array($pid, $formname));
495 if (!empty($tmp['encounter'])) {
496 $currvalue = lbf_current_value($frow, $tmp['form_id'], $tmp['encounter']);
499 else if ($source == 'E') {
500 // Visit attribute, get most recent value as of this visit.
501 // Even if the form already exists for this visit it may have a readonly value that only
502 // exists in a previous visit and was created from a different form.
503 $tmp = sqlQuery("SELECT sa.field_value FROM form_encounter AS e1 " .
504 "JOIN form_encounter AS e2 ON " .
505 "e2.pid = e1.pid AND (e2.date < e1.date OR (e2.date = e1.date AND e2.encounter <= e1.encounter)) " .
506 "JOIN shared_attributes AS sa ON " .
507 "sa.pid = e2.pid AND sa.encounter = e2.encounter AND sa.field_id = ?" .
508 "WHERE e1.pid = ? AND e1.encounter = ? " .
509 "ORDER BY e2.date DESC, e2.encounter DESC LIMIT 1",
510 array($field_id, $pid, $encounter));
511 if (isset($tmp['field_value'])) $currvalue = $tmp['field_value'];
513 } // End "P" option logic.
516 // Handle a data category (group) change.
517 if (strcmp($this_group, $last_group) != 0) {
518 end_group();
519 $group_seq = 'lbf' . substr($this_group, 0, 1);
520 $group_name = substr($this_group, 1);
521 $last_group = $this_group;
523 // If group name is blank, no checkbox or div.
524 if (strlen($this_group) > 1) {
525 echo "<div id='outerdiv_" . attr($group_seq) . "'>\n";
526 echo "<br /><span class='bold'><input type='checkbox' name='form_cb_" . attr($group_seq) . "' value='1' " .
527 "onclick='return divclick(this,\"div_" . attr(addslashes($group_seq)) . "\");'";
528 if ($display_style == 'block') echo " checked";
529 echo " /><b>" . text(xl_layout_label($group_name)) . "</b></span>\n";
530 echo "<div id='div_" . attr($group_seq) . "' class='section' style='display:" . attr($display_style) . ";'>\n";
532 // echo " <table border='0' cellpadding='0' width='100%'>\n";
533 echo " <table border='0' cellspacing='0' cellpadding='0' width='100%' class='lbfdata'>\n";
534 $display_style = 'none';
536 // Initialize historical data array and write date headers.
537 $historical_ids = array();
538 if ($formhistory > 0) {
539 echo " <tr>";
540 echo "<td colspan='" . attr($CPR) . "' align='right' class='bold'>";
541 if (empty($is_lbf)){
542 // Including actual date per IPPF request 2012-08-23.
543 echo oeFormatShortDate(substr($enrow['date'], 0, 10));
544 echo ' (' . htmlspecialchars(xl('Current')) . ')';
546 echo "&nbsp;</td>\n";
547 $hres = sqlStatement("SELECT f.form_id, fe.date " .
548 "FROM forms AS f, form_encounter AS fe WHERE " .
549 "f.pid = ? AND f.formdir = ? AND " .
550 "f.form_id != ? AND f.deleted = 0 AND " .
551 "fe.pid = f.pid AND fe.encounter = f.encounter " .
552 "ORDER BY fe.date DESC, f.encounter DESC, f.date DESC " .
553 "LIMIT ?",
554 array($pid, $formname, $formid, $formhistory));
555 // For some readings like vitals there may be multiple forms per encounter.
556 // We sort these sensibly, however only the encounter date is shown here;
557 // at some point we may wish to show also the data entry date/time.
558 while ($hrow = sqlFetchArray($hres)) {
559 echo "<td colspan='" . attr($CPR) . "' align='right' class='bold'>&nbsp;" .
560 text(oeFormatShortDate(substr($hrow['date'], 0, 10))) . "</td>\n";
561 $historical_ids[$hrow['form_id']] = '';
563 echo " </tr>";
568 // Handle starting of a new row.
569 if (($titlecols > 0 && $cell_count >= $CPR) || $cell_count == 0) {
570 end_row();
571 echo " <tr>";
572 // Clear historical data string.
573 foreach ($historical_ids as $key => $dummy) {
574 $historical_ids[$key] = '';
578 if ($item_count == 0 && $titlecols == 0) $titlecols = 1;
580 // First item is on the "left-border"
581 $leftborder = true;
583 // Handle starting of a new label cell.
584 if ($titlecols > 0) {
585 end_cell();
586 echo "<td valign='top' colspan='" . attr($titlecols) . "' nowrap";
587 echo " class='";
588 echo ($frow['uor'] == 2) ? "required" : "bold";
589 if ($graphable) echo " graph";
590 echo "'";
591 if ($cell_count == 2) echo " style='padding-left:10pt'";
592 // This ID is used by skip conditions and also show_graph().
593 echo " id='label_id_" . attr($field_id) . "'";
594 echo ">";
596 foreach ($historical_ids as $key => $dummy) {
597 $historical_ids[$key] .= "<td valign='top' colspan='" . attr($titlecols) . "' class='text' nowrap>";
600 $cell_count += $titlecols;
602 ++$item_count;
604 echo "<b>";
605 if ($frow['title']) echo text(xl_layout_label($frow['title']) . ":"); else echo "&nbsp;";
606 echo "</b>";
608 // Note the labels are not repeated in the history columns.
610 // Handle starting of a new data cell.
611 if ($datacols > 0) {
612 end_cell();
613 echo "<td valign='top' colspan='" . attr($datacols) . "' class='text'";
614 // This ID is used by skip conditions.
615 echo " id='value_id_" . attr($field_id) . "'";
616 if ($cell_count > 0) echo " style='padding-left:5pt'";
617 echo ">";
619 foreach ($historical_ids as $key => $dummy) {
620 $historical_ids[$key] .= "<td valign='top' align='right' colspan='" . attr($datacols) . "' class='text'>";
623 $cell_count += $datacols;
626 ++$item_count;
628 // Skip current-value fields for the display-only case.
629 if (empty($is_lbf)) {
630 if ($frow['edit_options'] == 'H')
631 echo generate_display_field($frow, $currvalue);
632 else
633 generate_form_field($frow, $currvalue);
636 // Append to historical data of other dates for this item.
637 foreach ($historical_ids as $key => $dummy) {
638 $value = lbf_current_value($frow, $key, 0);
639 $historical_ids[$key] .= generate_display_field($frow, $value);
644 end_group();
647 <p style='text-align:center'>
648 <?php if (empty($is_lbf)) { ?>
649 <input type='submit' name='bn_save' value='<?php echo xla('Save') ?>' />
650 <?php
651 if (function_exists($formname . '_additional_buttons')) {
652 // Allow the plug-in to insert more action buttons here.
653 call_user_func($formname . '_additional_buttons');
656 &nbsp;
657 <input type='button' value='<?php echo xla('Cancel') ?>' onclick="top.restoreSession();location='<?php echo $GLOBALS['form_exit_url']; ?>'" />
658 &nbsp;
659 <?php if ($form_is_graphable) { ?>
660 <input type='button' value='<?php echo xla('Show Graph') ?>' onclick="top.restoreSession();location='../../patient_file/encounter/trend_form.php?formname=<?php echo attr($formname); ?>'" />
661 &nbsp;
662 <?php } ?>
663 <?php } else { ?>
664 <input type='button' value='<?php echo xla('Back') ?>' onclick='window.history.back();' />
665 <?php } ?>
666 </p>
668 </form>
670 <!-- include support for the list-add selectbox feature -->
671 <?php include $GLOBALS['fileroot'] . "/library/options_listadd.inc"; ?>
673 <script language="JavaScript">
675 // Array of skip conditions for the checkSkipConditions() function.
676 var skipArray = [
677 <?php echo $condition_str; ?>
680 <?php echo $date_init; ?>
681 <?php
682 if (function_exists($formname . '_javascript_onload')) {
683 call_user_func($formname . '_javascript_onload');
686 // TBD: If $alertmsg, display it with a JavaScript alert().
688 // New form and this patient has a portal login and we have not loaded portal data.
689 // Check if there is portal data pending for this patient and form type.
690 if (!$formid && $GLOBALS['gbl_portal_cms_enable'] && $cmsportal_login && !$portalid) {
691 $portalres = cms_portal_call(array('action' => 'checkptform', 'form' => $formname, 'patient' => $cmsportal_login));
692 if ($portalres['errmsg']) {
693 die(text($portalres['errmsg'])); // TBD: Change to alertmsg
695 $portalid = $portalres['postid'];
696 if ($portalid) {
697 echo "if (confirm('" . xls('The portal has data for this patient and form. Load it now?') . "')) {\n";
698 echo " top.restoreSession();\n";
699 echo " document.location.href = 'load_form.php?formname=$formname&portalid=$portalid';\n";
700 echo "}\n";
704 </script>
706 </body>
707 </html>