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>.
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/formdata.inc.php");
33 require_once("$srcdir/formatting.inc.php");
34 if ($GLOBALS['gbl_portal_cms_enable']) {
35 require_once("$include_root/cmsportal/portal.inc.php");
38 $CPR = 4; // cells per row
42 // $is_lbf is defined in trend_form.php and indicates that we are being
43 // invoked from there; in that case the current encounter is irrelevant.
44 if (empty($is_lbf) && !$encounter) {
45 die("Internal error: we do not seem to be in an encounter!");
49 global $item_count, $cell_count, $historical_ids;
50 if ($item_count > 0) {
51 // echo " </td>";
54 foreach ($historical_ids as $key => $dummy) {
55 // $historical_ids[$key] .= " </td>";
56 $historical_ids[$key] .= "</td>";
64 global $cell_count, $CPR, $historical_ids;
66 if ($cell_count > 0) {
67 for (; $cell_count < $CPR; ++
$cell_count) {
69 foreach ($historical_ids as $key => $dummy) {
70 $historical_ids[$key] .= "<td></td>";
74 foreach ($historical_ids as $key => $dummy) {
75 echo $historical_ids[$key];
83 function end_group() {
85 if (strlen($last_group) > 0) {
88 // No div for an empty group name.
89 if (strlen($last_group) > 1) {
90 echo "</div>\n"; // div after checkbox
91 echo "</div>\n"; // outer div, including checkbox
96 $formname = isset($_GET['formname']) ?
$_GET['formname'] : '';
97 $formid = isset($_GET['id'] ) ?
intval($_GET['id']) : 0;
98 $portalid = isset($_GET['portalid']) ?
intval($_GET['portalid']) : 0;
100 // Get some info about this form.
101 $tmp = sqlQuery("SELECT title, option_value, notes FROM list_options WHERE " .
102 "list_id = 'lbfnames' AND option_id = ? AND activity = 1", array($formname));
103 $formtitle = $tmp['title'];
104 $formhistory = 0 +
$tmp['option_value'];
106 if (empty($is_lbf)) {
107 $fname = $GLOBALS['OE_SITE_DIR'] . "/LBF/$formname.plugin.php";
108 if (file_exists($fname)) include_once($fname);
111 // If Save was clicked, save the info.
113 if ($_POST['bn_save']) {
116 // Creating a new form. Get the new form_id by inserting and deleting a dummy row.
117 // This is necessary to create the form instance even if it has no native data.
118 $newid = sqlInsert("INSERT INTO lbf_data " .
119 "( field_id, field_value ) VALUES ( '', '' )");
120 sqlStatement("DELETE FROM lbf_data WHERE form_id = ? AND " .
121 "field_id = ''", array($newid));
122 addForm($encounter, $formtitle, $newid, $formname, $pid, $userauthorized);
125 $fres = sqlStatement("SELECT * FROM layout_options " .
126 "WHERE form_id = ? AND uor > 0 AND field_id != '' AND " .
127 "edit_options != 'H' AND edit_options NOT LIKE '%0%' " .
128 "ORDER BY group_name, seq", array($formname) );
129 while ($frow = sqlFetchArray($fres)) {
130 $field_id = $frow['field_id'];
131 $data_type = $frow['data_type'];
132 // If the field was not in the web form, skip it.
133 // Except if it's checkboxes, if unchecked they are not returned.
135 // if ($data_type != 21 && !isset($_POST["form_$field_id"])) continue;
137 // The above statement commented out 2015-01-12 because a LBF plugin might conditionally
138 // disable a field that is not applicable, and we need the ability to clear out the old
139 // garbage in there so it does not show up in the "report" view of the data. So we will
140 // trust that it's OK to clear any field that is defined in the layout but not returned
143 $value = get_layout_form_value($frow);
144 // If edit option P or Q, save to the appropriate different table and skip the rest.
145 $source = $frow['source'];
146 if ($source == 'D' ||
$source == 'H') {
147 // Save to patient_data, employer_data or history_data.
148 if ($source == 'H') {
149 $new = array($field_id => $value);
150 updateHistoryData($pid, $new);
152 else if (strpos($field_id, 'em_') === 0) {
153 $field_id = substr($field_id, 3);
154 $new = array($field_id => $value);
155 updateEmployerData($pid, $new);
158 $esc_field_id = escape_sql_column_name($field_id, array('patient_data'));
159 sqlStatement("UPDATE patient_data SET `$esc_field_id` = ? WHERE pid = ?",
160 array($value, $pid));
164 else if ($source == 'E') {
165 // Save to shared_attributes. Can't delete entries for empty fields because with the P option
166 // it's important to know when a current empty value overrides a previous value.
167 sqlStatement("REPLACE INTO shared_attributes SET " .
168 "pid = ?, encounter = ?, field_id = ?, last_update = NOW(), " .
169 "user_id = ?, field_value = ?",
170 array($pid, $encounter, $field_id, $_SESSION['authUserID'], $value));
173 else if ($source == 'V') {
174 // Save to form_encounter.
175 $esc_field_id = escape_sql_column_name($field_id, array('form_encounter'));
176 sqlStatement("UPDATE form_encounter SET `$esc_field_id` = ? WHERE " .
177 "pid = ? AND encounter = ?",
178 array($value, $pid, $encounter));
181 // It's a normal form field, save to lbf_data.
182 if ($formid) { // existing form
184 $query = "DELETE FROM lbf_data WHERE " .
185 "form_id = ? AND field_id = ?";
186 sqlStatement($query, array($formid, $field_id));
189 $query = "REPLACE INTO lbf_data SET field_value = ?, " .
190 "form_id = ?, field_id = ?";
191 sqlStatement($query,array($value, $formid, $field_id));
196 sqlStatement("INSERT INTO lbf_data " .
197 "( form_id, field_id, field_value ) VALUES ( ?, ?, ? )",
198 array($newid, $field_id, $value));
204 // Delete the request from the portal.
205 $result = cms_portal_call(array('action' => 'delpost', 'postid' => $portalid));
206 if ($result['errmsg']) {
207 die(text($result['errmsg']));
211 // Support custom behavior at save time, such as going to another form.
212 if (function_exists($formname . '_save_exit')) {
213 if (call_user_func($formname . '_save_exit')) exit;
215 formHeader("Redirecting....");
224 <?php
html_header_show();?
>
225 <link rel
=stylesheet href
="<?php echo $css_header;?>" type
="text/css">
228 td
, input
, select
, textarea
{
229 font
-family
: Arial
, Helvetica
, sans
-serif
;
236 border
-color
: #0000ff;
243 <style type
="text/css">@import
url(../../../library
/dynarch_calendar
.css
);</style
>
245 <link rel
="stylesheet" type
="text/css" href
="<?php echo $GLOBALS['webroot'] ?>/library/js/fancybox/jquery.fancybox-1.2.6.css" media
="screen" />
246 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/dialog.js?v=<?php echo $v_js_includes; ?>"></script
>
247 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-3-2/index.js"></script
>
248 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/js/common.js"></script
>
249 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/js/fancybox/jquery.fancybox-1.2.6.js"></script
>
250 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery-ui.js"></script
>
251 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery.easydrag.handler.beta2.js"></script
>
252 <script type
="text/javascript" src
="../../../library/textformat.js"></script
>
253 <script type
="text/javascript" src
="../../../library/dynarch_calendar.js"></script
>
254 <?php
include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?
>
255 <script type
="text/javascript" src
="../../../library/dynarch_calendar_setup.js"></script
>
256 <?php
include_once("{$GLOBALS['srcdir']}/options.js.php"); ?
>
258 <!-- LiterallyCanvas support
-->
259 <?php
echo lbf_canvas_head(); ?
>
261 <script language
="JavaScript">
263 // Support for beforeunload handler.
264 var somethingChanged
= false;
266 $
(document
).ready(function() {
269 if (window
.enable_modals
) {
275 if (window
.checkSkipConditions
) {
276 checkSkipConditions();
279 $
(".iframe_medium").fancybox({
280 'overlayOpacity' : 0.0,
281 'showCloseButton' : true,
286 // add drag and drop functionality to fancybox
287 $
("#fancy_outer").easydrag();
290 // Support for beforeunload handler.
291 $
('.lbfdata input, .lbfdata select, .lbfdata textarea').change(function() {
292 somethingChanged
= true;
294 window
.addEventListener("beforeunload", function (e
) {
295 if (somethingChanged
&& !top
.timed_out
) {
296 var msg
= "<?php echo xls('You have unsaved changes.'); ?>";
297 e
.returnValue
= msg
; // Gecko, Trident, Chrome 34+
298 return msg
; // Gecko, WebKit, Chrome <34
304 var mypcc
= '<?php echo $GLOBALS['phone_country_code
'] ?>';
306 // Supports customizable forms.
307 function divclick(cb
, divid
) {
308 var divstyle
= document
.getElementById(divid
).style
;
310 divstyle
.display
= 'block';
312 divstyle
.display
= 'none';
317 // The ID of the input element to receive a found code.
318 var current_sel_name
= '';
320 // This is for callback by the find-code popup.
321 // Appends to or erases the current list of related codes.
322 function set_related(codetype
, code
, selector
, codedesc
) {
323 var f
= document
.forms
[0];
324 // frc will be the input element containing the codes.
325 // frcd, if set, will be the input element containing their descriptions.
326 var frc
= f
[current_sel_name
];
328 var matches
= current_sel_name
.match(/^
(.*)__desc$
/);
334 var sd
= frcd ? frcd
.value
: s
;
336 if (codetype
!= 'PROD') {
337 if (s
.indexOf(codetype +
':') == 0 || s
.indexOf(';' + codetype +
':') > 0) {
338 return '<?php echo xl('A code of this type is already selected
. Erase the field first
if you need to replace it
.') ?>';
345 s +
= codetype +
':' + code
;
352 if (frcd
) frcd
.value
= sd
;
356 // This invokes the find-code popup.
357 function sel_related(elem
, codetype
) {
358 current_sel_name
= elem
.name
;
359 var url
= '<?php echo $rootdir ?>/patient_file/encounter/find_code_popup.php';
360 if (codetype
) url +
= '?codetype=' + codetype
;
361 dlgopen(url
, '_blank', 500, 400);
364 // Compute the length of a string without leading and trailing spaces.
365 function trimlen(s
) {
367 var j
= s
.length
- 1;
368 for (; i
<= j
&& s
.charAt(i
) == ' '; ++i
);
369 for (; i
<= j
&& s
.charAt(j
) == ' '; --j
);
374 // Validation logic for form submission.
375 function validate(f
) {
376 <?php
generate_layout_validation($formname); ?
>
377 somethingChanged
= false; // turn off "are you sure you want to leave"
378 top
.restoreSession();
382 <?php
if (function_exists($formname . '_javascript')) call_user_func($formname . '_javascript'); ?
>
387 <body
<?php
echo $top_bg_line; ?
> topmargin
="0" rightmargin
="0" leftmargin
="2" bottommargin
="0" marginwidth
="2" marginheight
="0">
390 echo "<form method='post' " .
391 "action='$rootdir/forms/LBF/new.php?formname=$formname&id=$formid&portalid=$portalid' " .
392 "onsubmit='return validate(this)'>\n";
394 $cmsportal_login = '';
396 if (empty($is_lbf)) {
397 $enrow = sqlQuery("SELECT p.fname, p.mname, p.lname, p.cmsportal_login, " .
399 "form_encounter AS fe, forms AS f, patient_data AS p WHERE " .
400 "p.pid = ? AND f.pid = p.pid AND f.encounter = ? AND " .
401 "f.formdir = 'newpatient' AND f.deleted = 0 AND " .
402 "fe.id = f.form_id LIMIT 1", array($pid, $encounter));
403 echo "<p class='title' style='margin-top:8px;margin-bottom:8px;text-align:center'>\n";
404 echo text($formtitle) . " " . xlt('for') . ' ';
405 echo text($enrow['fname']) . ' ' . text($enrow['mname']) . ' ' . text($enrow['lname']);
406 echo ' ' . xlt('on') . ' ' . text(oeFormatShortDate(substr($enrow['date'], 0, 10)));
408 $cmsportal_login = $enrow['cmsportal_login'];
410 // If loading data from portal, get the data.
411 if ($GLOBALS['gbl_portal_cms_enable'] && $portalid) {
412 $portalres = cms_portal_call(array('action' => 'getpost', 'postid' => $portalid));
413 if ($portalres['errmsg']) {
414 die(text($portalres['errmsg']));
419 <!-- This is where a chart might display
. -->
420 <div id
="chart"></div
>
423 $shrow = getHistoryData($pid);
425 $fres = sqlStatement("SELECT * FROM layout_options " .
426 "WHERE form_id = ? AND uor > 0 " .
427 "ORDER BY group_name, seq", array($formname) );
431 $display_style = 'block';
433 // This is an array keyed on forms.form_id for other occurrences of this
434 // form type. The maximum number of such other occurrences to display is
435 // in list_options.option_value for this form's list item. Values in this
436 // array are work areas for building the ending HTML for each displayed row.
438 $historical_ids = array();
440 // True if any data items in this form can be graphed.
441 $form_is_graphable = false;
445 while ($frow = sqlFetchArray($fres)) {
446 $this_group = $frow['group_name'];
447 $titlecols = $frow['titlecols'];
448 $datacols = $frow['datacols'];
449 $data_type = $frow['data_type'];
450 $field_id = $frow['field_id'];
451 $list_id = $frow['list_id'];
452 $edit_options = $frow['edit_options'];
453 $source = $frow['source'];
455 $graphable = strpos($edit_options, 'G') !== FALSE;
456 if ($graphable) $form_is_graphable = true;
458 // Accumulate skip conditions into a JavaScript string literal.
459 $conditions = empty($frow['conditions']) ?
array() : unserialize($frow['conditions']);
460 foreach ($conditions as $condition) {
461 if (empty($condition['id'])) continue;
462 $andor = empty($condition['andor']) ?
'' : $condition['andor'];
463 if ($condition_str) $condition_str .= ",\n";
464 $condition_str .= "{" .
465 "target:'" . addslashes($field_id) . "', " .
466 "id:'" . addslashes($condition['id']) . "', " .
467 "itemid:'" . addslashes($condition['itemid']) . "', " .
468 "operator:'" . addslashes($condition['operator']) . "', " .
469 "value:'" . addslashes($condition['value']) . "', " .
470 "andor:'" . addslashes($andor) . "'}";
475 if ($frow['edit_options'] == 'H') {
476 // This data comes from static history
477 if (isset($shrow[$field_id])) $currvalue = $shrow[$field_id];
479 if (!$formid && $portalres) {
480 // Copying CMS Portal form data into this field if appropriate.
481 $currvalue = cms_field_to_lbf($data_type, $field_id, $portalres['fields']);
483 if ($currvalue === '') {
484 $currvalue = lbf_current_value($frow, $formid, $is_lbf ?
0 : $encounter);
486 if ($currvalue === FALSE) continue; // column does not exist, should not happen
487 // Handle "P" edit option to default to the previous value of a form field.
488 if (!$is_lbf && empty($currvalue) && strpos($edit_options, 'P') !== FALSE) {
489 if ($source == 'F' && !$formid) {
490 // Form attribute for new form, get value from most recent form instance.
491 // Form attributes of existing forms are expected to have existing values.
492 $tmp = sqlQuery("SELECT encounter, form_id FROM forms WHERE " .
493 "pid = ? AND formdir = ? AND deleted = 0 " .
494 "ORDER BY date DESC LIMIT 1",
495 array($pid, $formname));
496 if (!empty($tmp['encounter'])) {
497 $currvalue = lbf_current_value($frow, $tmp['form_id'], $tmp['encounter']);
500 else if ($source == 'E') {
501 // Visit attribute, get most recent value as of this visit.
502 // Even if the form already exists for this visit it may have a readonly value that only
503 // exists in a previous visit and was created from a different form.
504 $tmp = sqlQuery("SELECT sa.field_value FROM form_encounter AS e1 " .
505 "JOIN form_encounter AS e2 ON " .
506 "e2.pid = e1.pid AND (e2.date < e1.date OR (e2.date = e1.date AND e2.encounter <= e1.encounter)) " .
507 "JOIN shared_attributes AS sa ON " .
508 "sa.pid = e2.pid AND sa.encounter = e2.encounter AND sa.field_id = ?" .
509 "WHERE e1.pid = ? AND e1.encounter = ? " .
510 "ORDER BY e2.date DESC, e2.encounter DESC LIMIT 1",
511 array($field_id, $pid, $encounter));
512 if (isset($tmp['field_value'])) $currvalue = $tmp['field_value'];
514 } // End "P" option logic.
517 // Handle a data category (group) change.
518 if (strcmp($this_group, $last_group) != 0) {
520 $group_seq = 'lbf' . substr($this_group, 0, 1);
521 $group_name = substr($this_group, 1);
522 $last_group = $this_group;
524 // If group name is blank, no checkbox or div.
525 if (strlen($this_group) > 1) {
526 echo "<div id='outerdiv_" . attr($group_seq) . "'>\n";
527 echo "<br /><span class='bold'><input type='checkbox' name='form_cb_" . attr($group_seq) . "' value='1' " .
528 "onclick='return divclick(this,\"div_" . attr(addslashes($group_seq)) . "\");'";
529 if ($display_style == 'block') echo " checked";
530 echo " /><b>" . text(xl_layout_label($group_name)) . "</b></span>\n";
531 echo "<div id='div_" . attr($group_seq) . "' class='section' style='display:" . attr($display_style) . ";'>\n";
533 // echo " <table border='0' cellpadding='0' width='100%'>\n";
534 echo " <table border='0' cellspacing='0' cellpadding='0' width='100%' class='lbfdata'>\n";
535 $display_style = 'none';
537 // Initialize historical data array and write date headers.
538 $historical_ids = array();
539 if ($formhistory > 0) {
541 echo "<td colspan='" . attr($CPR) . "' align='right' class='bold'>";
543 // Including actual date per IPPF request 2012-08-23.
544 echo oeFormatShortDate(substr($enrow['date'], 0, 10));
545 echo ' (' . htmlspecialchars(xl('Current')) . ')';
547 echo " </td>\n";
548 $hres = sqlStatement("SELECT f.form_id, fe.date " .
549 "FROM forms AS f, form_encounter AS fe WHERE " .
550 "f.pid = ? AND f.formdir = ? AND " .
551 "f.form_id != ? AND f.deleted = 0 AND " .
552 "fe.pid = f.pid AND fe.encounter = f.encounter " .
553 "ORDER BY fe.date DESC, f.encounter DESC, f.date DESC " .
555 array($pid, $formname, $formid, $formhistory));
556 // For some readings like vitals there may be multiple forms per encounter.
557 // We sort these sensibly, however only the encounter date is shown here;
558 // at some point we may wish to show also the data entry date/time.
559 while ($hrow = sqlFetchArray($hres)) {
560 echo "<td colspan='" . attr($CPR) . "' align='right' class='bold'> " .
561 text(oeFormatShortDate(substr($hrow['date'], 0, 10))) . "</td>\n";
562 $historical_ids[$hrow['form_id']] = '';
569 // Handle starting of a new row.
570 if (($titlecols > 0 && $cell_count >= $CPR) ||
$cell_count == 0) {
573 // Clear historical data string.
574 foreach ($historical_ids as $key => $dummy) {
575 $historical_ids[$key] = '';
579 if ($item_count == 0 && $titlecols == 0) $titlecols = 1;
581 // First item is on the "left-border"
584 // Handle starting of a new label cell.
585 if ($titlecols > 0) {
587 echo "<td valign='top' colspan='" . attr($titlecols) . "' nowrap";
589 echo ($frow['uor'] == 2) ?
"required" : "bold";
590 if ($graphable) echo " graph";
592 if ($cell_count == 2) echo " style='padding-left:10pt'";
593 // This ID is used by skip conditions and also show_graph().
594 echo " id='label_id_" . attr($field_id) . "'";
597 foreach ($historical_ids as $key => $dummy) {
598 $historical_ids[$key] .= "<td valign='top' colspan='" . attr($titlecols) . "' class='text' nowrap>";
601 $cell_count +
= $titlecols;
606 if ($frow['title']) echo text(xl_layout_label($frow['title']) . ":"); else echo " ";
609 // Note the labels are not repeated in the history columns.
611 // Handle starting of a new data cell.
614 echo "<td valign='top' colspan='" . attr($datacols) . "' class='text'";
615 // This ID is used by skip conditions.
616 echo " id='value_id_" . attr($field_id) . "'";
617 if ($cell_count > 0) echo " style='padding-left:5pt'";
620 foreach ($historical_ids as $key => $dummy) {
621 $historical_ids[$key] .= "<td valign='top' align='right' colspan='" . attr($datacols) . "' class='text'>";
624 $cell_count +
= $datacols;
629 // Skip current-value fields for the display-only case.
630 if (empty($is_lbf)) {
631 if ($frow['edit_options'] == 'H')
632 echo generate_display_field($frow, $currvalue);
634 generate_form_field($frow, $currvalue);
637 // Append to historical data of other dates for this item.
638 foreach ($historical_ids as $key => $dummy) {
639 $value = lbf_current_value($frow, $key, 0);
640 $historical_ids[$key] .= generate_display_field($frow, $value);
648 <p style
='text-align:center'>
649 <?php
if (empty($is_lbf)) { ?
>
650 <input type
='submit' name
='bn_save' value
='<?php echo xla('Save
') ?>' />
652 if (function_exists($formname . '_additional_buttons')) {
653 // Allow the plug-in to insert more action buttons here.
654 call_user_func($formname . '_additional_buttons');
658 <input type
='button' value
='<?php echo xla('Cancel
') ?>' onclick
="top.restoreSession();location='<?php echo $GLOBALS['form_exit_url']; ?>'" />
660 <?php
if ($form_is_graphable) { ?
>
661 <input type
='button' value
='<?php echo xla('Show Graph
') ?>' onclick
="top.restoreSession();location='../../patient_file/encounter/trend_form.php?formname=<?php echo attr($formname); ?>'" />
665 <input type
='button' value
='<?php echo xla('Back
') ?>' onclick
='window.history.back();' />
671 <!-- include support
for the
list-add selectbox feature
-->
672 <?php
include $GLOBALS['fileroot'] . "/library/options_listadd.inc"; ?
>
674 <script language
="JavaScript">
676 // Array of skip conditions for the checkSkipConditions() function.
678 <?php
echo $condition_str; ?
>
681 <?php
echo $date_init; ?
>
683 if (function_exists($formname . '_javascript_onload')) {
684 call_user_func($formname . '_javascript_onload');
687 // TBD: If $alertmsg, display it with a JavaScript alert().
689 // New form and this patient has a portal login and we have not loaded portal data.
690 // Check if there is portal data pending for this patient and form type.
691 if (!$formid && $GLOBALS['gbl_portal_cms_enable'] && $cmsportal_login && !$portalid) {
692 $portalres = cms_portal_call(array('action' => 'checkptform', 'form' => $formname, 'patient' => $cmsportal_login));
693 if ($portalres['errmsg']) {
694 die(text($portalres['errmsg'])); // TBD: Change to alertmsg
696 $portalid = $portalres['postid'];
698 echo "if (confirm('" . xls('The portal has data for this patient and form. Load it now?') . "')) {\n";
699 echo " top.restoreSession();\n";
700 echo " document.location.href = 'load_form.php?formname=$formname&portalid=$portalid';\n";