2 // Copyright (C) 2007-2013 Rod Roark <rod@sunsetsystems.com>
3 // Copyright © 2010 by Andrew Moore <amoore@cpan.org>
4 // Copyright © 2010 by "Boyd Stephen Smith Jr." <bss@iguanasuicide.net>
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // Functions for managing the lists and layouts
13 // Note: there are translation wrappers for the lists and layout labels
14 // at library/translation.inc.php. The functions are titled
15 // xl_list_label() and xl_layout_label() and are controlled by the
16 // $GLOBALS['translate_lists'] and $GLOBALS['translate_layout']
17 // flags in globals.php
19 // Documentation for layout_options.edit_options:
21 // C = Capitalize first letter of each word (text fields)
22 // D = Check for duplicates in New Patient form
23 // G = Graphable (for numeric fields in forms supporting historical data)
24 // H = Read-only field copied from static history
25 // L = Lab Order ("ord_lab") types only (address book)
26 // N = Show in New Patient form
27 // O = Procedure Order ("ord_*") types only (address book)
28 // R = Distributor types only (address book)
29 // T = Use description as default Text
30 // U = Capitalize all letters (text fields)
31 // V = Vendor types only (address book)
32 // 1 = Write Once (not editable when not empty) (text fields)
34 require_once("formdata.inc.php");
35 require_once("formatting.inc.php");
36 require_once("user.inc");
37 require_once("patient.inc");
38 require_once("lists.inc");
42 function get_pharmacies() {
43 return sqlStatement("SELECT d.id, d.name, a.line1, a.city, " .
44 "p.area_code, p.prefix, p.number FROM pharmacies AS d " .
45 "LEFT OUTER JOIN addresses AS a ON a.foreign_id = d.id " .
46 "LEFT OUTER JOIN phone_numbers AS p ON p.foreign_id = d.id " .
48 "ORDER BY name, area_code, prefix, number");
51 // Function to generate a drop-list.
53 function generate_select_list($tag_name, $list_id, $currvalue, $title, $empty_name = ' ', $class = '',
54 $onchange = '', $tag_id = '', $custom_attributes = null, $multiple = false, $backup_list = '') {
57 $tag_name_esc = attr($tag_name);
60 $tag_name_esc = $tag_name_esc . "[]";
62 $s .= "<select name='$tag_name_esc'";
65 $s .= " multiple='multiple'";
68 $tag_id_esc = $tag_name_esc;
70 $tag_id_esc = attr($tag_id);
74 $tag_id_esc = $tag_id_esc . "[]";
76 $s .= " id='$tag_id_esc'";
79 $class_esc = attr($class);
80 $s .= " class='$class_esc'";
83 $s .= " onchange='$onchange'";
85 if ($custom_attributes != null && is_array ( $custom_attributes )) {
86 foreach ( $custom_attributes as $attr => $val ) {
87 if (isset ( $custom_attributes [$attr] )) {
88 $s .= " " . attr($attr) . "='" . attr($val) . "'";
92 $selectTitle = attr($title);
93 $s .= " title='$selectTitle'>";
94 $selectEmptyName = xlt($empty_name);
96 $s .= "<option value=''>" . $selectEmptyName . "</option>";
97 $lres = sqlStatement("SELECT * FROM list_options WHERE list_id = ? ORDER BY seq, title", array($list_id));
98 $got_selected = FALSE;
100 while ( $lrow = sqlFetchArray ( $lres ) ) {
101 $selectedValues = explode ( "|", $currvalue );
103 $optionValue = attr($lrow ['option_id']);
104 $s .= "<option value='$optionValue'";
106 if ($multiple && (strlen ( $currvalue ) == 0 && $lrow ['is_default']) ||
(strlen ( $currvalue ) > 0 && in_array ( $lrow ['option_id'], $selectedValues ))) {
108 $got_selected = TRUE;
111 $optionLabel = text(xl_list_label($lrow ['title']));
112 $s .= ">$optionLabel</option>\n";
115 if (!$got_selected && strlen ( $currvalue ) > 0 && !$multiple) {
116 $list_id = $backup_list;
117 $lrow = sqlQuery("SELECT title FROM list_options WHERE list_id = ? AND option_id = ?", array($list_id,$currvalue));
119 if ($lrow > 0 && !empty($backup_list)) {
120 $selected = text(xl_list_label($lrow ['title']));
121 $s .= "<option value='$currescaped' selected> $selected </option>";
124 $s .= "<option value='$currescaped' selected>* $currescaped *</option>";
126 $fontTitle = xlt('Please choose a valid selection from the list.');
127 $fontText = xlt( 'Fix this' );
128 $s .= " <font color='red' title='$fontTitle'>$fontText!</font>";
131 } else if (!$got_selected && strlen ( $currvalue ) > 0 && $multiple) {
132 //if not found in main list, display all selected values that exist in backup list
133 $list_id = $backup_list;
135 $lres_backup = sqlStatement("SELECT * FROM list_options WHERE list_id = ? ORDER BY seq, title", array($list_id));
137 $got_selected_backup = FALSE;
138 if (!empty($backup_list)) {
139 while ( $lrow_backup = sqlFetchArray ( $lres_backup ) ) {
140 $selectedValues = explode ( "|", $currvalue );
142 $optionValue = attr($lrow ['option_id']);
144 if ($multiple && (strlen ( $currvalue ) == 0 && $lrow_backup ['is_default']) ||
145 (strlen ( $currvalue ) > 0 && in_array ( $lrow_backup ['option_id'], $selectedValues ))) {
146 $s .= "<option value='$optionValue'";
148 $optionLabel = text(xl_list_label($lrow_backup ['title']));
149 $s .= ">$optionLabel</option>\n";
150 $got_selected_backup = TRUE;
154 if (!$got_selected_backup) {
155 $s .= "<option value='$currescaped' selected>* $currescaped *</option>";
157 $fontTitle = xlt('Please choose a valid selection from the list.');
158 $fontText = xlt( 'Fix this' );
159 $s .= " <font color='red' title='$fontTitle'>$fontText!</font>";
170 // $frow is a row from the layout_options table.
171 // $currvalue is the current value, if any, of the associated item.
173 function generate_form_field($frow, $currvalue) {
174 global $rootdir, $date_init, $ISSUE_TYPES;
176 $currescaped = htmlspecialchars($currvalue, ENT_QUOTES
);
178 $data_type = $frow['data_type'];
179 $field_id = $frow['field_id'];
180 $list_id = $frow['list_id'];
181 $backup_list = $frow['list_backup_id'];
183 // escaped variables to use in html
184 $field_id_esc= htmlspecialchars( $field_id, ENT_QUOTES
);
185 $list_id_esc = htmlspecialchars( $list_id, ENT_QUOTES
);
187 // Added 5-09 by BM - Translate description if applicable
188 $description = (isset($frow['description']) ?
htmlspecialchars(xl_layout_label($frow['description']), ENT_QUOTES
) : '');
190 // Support edit option T which assigns the (possibly very long) description as
191 // the default value.
192 if (strpos($frow['edit_options'], 'T') !== FALSE) {
193 if (strlen($currescaped) == 0) $currescaped = $description;
194 // Description used in this way is not suitable as a title.
198 // added 5-2009 by BM to allow modification of the 'empty' text title field.
199 // Can pass $frow['empty_title'] with this variable, otherwise
200 // will default to 'Unassigned'.
201 // modified 6-2009 by BM to allow complete skipping of the 'empty' text title
202 // if make $frow['empty_title'] equal to 'SKIP'
204 if (isset($frow['empty_title'])) {
205 if ($frow['empty_title'] == "SKIP") {
206 //do not display an 'empty' choice
208 $empty_title = "Unassigned";
211 $empty_title = $frow['empty_title'];
215 $empty_title = "Unassigned";
218 // generic single-selection list or Race and Ethnicity.
219 // These data types support backup lists.
220 if ($data_type == 1 ||
$data_type == 33) {
221 echo generate_select_list("form_$field_id", $list_id, $currvalue,
222 $description, $showEmpty ?
$empty_title : '', '', $onchange, '', null, false, $backup_list);
226 else if ($data_type == 2) {
227 $fldlength = htmlspecialchars( $frow['fld_length'], ENT_QUOTES
);
228 $maxlength = $frow['max_length'];
229 $string_maxlength = "";
230 // if max_length is set to zero, then do not set a maxlength
231 if ($maxlength) $string_maxlength = "maxlength='".attr($maxlength)."'";
232 echo "<input type='text'" .
233 " name='form_$field_id_esc'" .
234 " id='form_$field_id_esc'" .
235 " size='$fldlength'" .
236 " $string_maxlength" .
237 " title='$description'" .
238 " value='$currescaped'";
239 if (strpos($frow['edit_options'], 'C') !== FALSE)
240 echo " onchange='capitalizeMe(this)'";
241 else if (strpos($frow['edit_options'], 'U') !== FALSE)
242 echo " onchange='this.value = this.value.toUpperCase()'";
243 $tmp = htmlspecialchars( $GLOBALS['gbl_mask_patient_id'], ENT_QUOTES
);
244 if ($field_id == 'pubpid' && strlen($tmp) > 0) {
245 echo " onkeyup='maskkeyup(this,\"$tmp\")'";
246 echo " onblur='maskblur(this,\"$tmp\")'";
248 if (strpos($frow['edit_options'], '1') !== FALSE && strlen($currescaped) > 0)
253 // long or multi-line text field
254 else if ($data_type == 3) {
255 $textCols = htmlspecialchars( $frow['fld_length'], ENT_QUOTES
);
256 $textRows = htmlspecialchars( $frow['fld_rows'], ENT_QUOTES
);
258 " name='form_$field_id_esc'" .
259 " id='form_$field_id_esc'" .
260 " title='$description'" .
261 " cols='$textCols'" .
262 " rows='$textRows'>" .
263 $currescaped . "</textarea>";
267 else if ($data_type == 4) {
268 echo "<input type='text' size='10' name='form_$field_id_esc' id='form_$field_id_esc'" .
269 " value='$currescaped'" .
270 " title='$description'" .
271 " onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)' />" .
272 "<img src='$rootdir/pic/show_calendar.gif' align='absbottom' width='24' height='22'" .
273 " id='img_$field_id_esc' border='0' alt='[?]' style='cursor:pointer'" .
274 " title='" . htmlspecialchars( xl('Click here to choose a date'), ENT_QUOTES
) . "' />";
275 $date_init .= " Calendar.setup({inputField:'form_$field_id', ifFormat:'%Y-%m-%d', button:'img_$field_id'});\n";
278 // provider list, local providers only
279 else if ($data_type == 10) {
280 $ures = sqlStatement("SELECT id, fname, lname, specialty FROM users " .
281 "WHERE active = 1 AND ( info IS NULL OR info NOT LIKE '%Inactive%' ) " .
282 "AND authorized = 1 " .
283 "ORDER BY lname, fname");
284 echo "<select name='form_$field_id_esc' id='form_$field_id_esc' title='$description'>";
285 echo "<option value=''>" . xlt($empty_title) . "</option>";
286 $got_selected = false;
287 while ($urow = sqlFetchArray($ures)) {
288 $uname = text($urow['fname'] . ' ' . $urow['lname']);
289 $optionId = attr($urow['id']);
290 echo "<option value='$optionId'";
291 if ($urow['id'] == $currvalue) {
293 $got_selected = true;
295 echo ">$uname</option>";
297 if (!$got_selected && strlen($currvalue) > 0) {
298 echo "<option value='" . attr($currvalue) . "' selected>* " . text($currvalue) . " *</option>";
300 echo " <font color='red' title='" . xla('Please choose a valid selection from the list.') . "'>" . xlt('Fix this') . "!</font>";
307 // provider list, including address book entries with an NPI number
308 else if ($data_type == 11) {
309 $ures = sqlStatement("SELECT id, fname, lname, specialty FROM users " .
310 "WHERE active = 1 AND ( info IS NULL OR info NOT LIKE '%Inactive%' ) " .
311 "AND ( authorized = 1 OR ( username = '' AND npi != '' ) ) " .
312 "ORDER BY lname, fname");
313 echo "<select name='form_$field_id_esc' id='form_$field_id_esc' title='$description'>";
314 echo "<option value=''>" . xlt('Unassigned') . "</option>";
315 $got_selected = false;
316 while ($urow = sqlFetchArray($ures)) {
317 $uname = text($urow['fname'] . ' ' . $urow['lname']);
318 $optionId = attr($urow['id']);
319 echo "<option value='$optionId'";
320 if ($urow['id'] == $currvalue) {
322 $got_selected = true;
324 echo ">$uname</option>";
326 if (!$got_selected && strlen($currvalue) > 0) {
327 echo "<option value='" . attr($currvalue) . "' selected>* " . text($currvalue) . " *</option>";
329 echo " <font color='red' title='" . xla('Please choose a valid selection from the list.') . "'>" . xlt('Fix this') . "!</font>";
337 else if ($data_type == 12) {
338 echo "<select name='form_$field_id_esc' id='form_$field_id_esc' title='$description'>";
339 echo "<option value='0'></option>";
340 $pres = get_pharmacies();
341 $got_selected = false;
342 while ($prow = sqlFetchArray($pres)) {
344 $optionValue = htmlspecialchars( $key, ENT_QUOTES
);
345 $optionLabel = htmlspecialchars( $prow['name'] . ' ' . $prow['area_code'] . '-' .
346 $prow['prefix'] . '-' . $prow['number'] . ' / ' .
347 $prow['line1'] . ' / ' . $prow['city'], ENT_NOQUOTES
);
348 echo "<option value='$optionValue'";
349 if ($currvalue == $key) {
351 $got_selected = true;
353 echo ">$optionLabel</option>";
355 if (!$got_selected && strlen($currvalue) > 0) {
356 echo "<option value='" . attr($currvalue) . "' selected>* " . text($currvalue) . " *</option>";
358 echo " <font color='red' title='" . xla('Please choose a valid selection from the list.') . "'>" . xlt('Fix this') . "!</font>";
366 else if ($data_type == 13) {
367 echo "<select name='form_$field_id_esc' id='form_$field_id_esc' title='$description'>";
368 echo "<option value=''> </option>";
369 $squads = acl_get_squads();
371 foreach ($squads as $key => $value) {
372 $optionValue = htmlspecialchars( $key, ENT_QUOTES
);
373 $optionLabel = htmlspecialchars( $value[3], ENT_NOQUOTES
);
374 echo "<option value='$optionValue'";
375 if ($currvalue == $key) echo " selected";
376 echo ">$optionLabel</option>\n";
382 // Address book, preferring organization name if it exists and is not in
383 // parentheses, and excluding local users who are not providers.
384 // Supports "referred to" practitioners and facilities.
385 // Alternatively the letter L in edit_options means that abook_type
386 // must be "ord_lab", indicating types used with the procedure
387 // lab ordering system.
388 // Alternatively the letter O in edit_options means that abook_type
389 // must begin with "ord_", indicating types used with the procedure
391 // Alternatively the letter V in edit_options means that abook_type
392 // must be "vendor", indicating the Vendor type.
393 // Alternatively the letter R in edit_options means that abook_type
394 // must be "dist", indicating the Distributor type.
395 else if ($data_type == 14) {
396 if (strpos($frow['edit_options'], 'L') !== FALSE)
397 $tmp = "abook_type = 'ord_lab'";
398 else if (strpos($frow['edit_options'], 'O') !== FALSE)
399 $tmp = "abook_type LIKE 'ord\\_%'";
400 else if (strpos($frow['edit_options'], 'V') !== FALSE)
401 $tmp = "abook_type LIKE 'vendor%'";
402 else if (strpos($frow['edit_options'], 'R') !== FALSE)
403 $tmp = "abook_type LIKE 'dist'";
405 $tmp = "( username = '' OR authorized = 1 )";
406 $ures = sqlStatement("SELECT id, fname, lname, organization, username FROM users " .
407 "WHERE active = 1 AND ( info IS NULL OR info NOT LIKE '%Inactive%' ) " .
409 "ORDER BY organization, lname, fname");
410 echo "<select name='form_$field_id_esc' id='form_$field_id_esc' title='$description'>";
411 echo "<option value=''>" . htmlspecialchars( xl('Unassigned'), ENT_NOQUOTES
) . "</option>";
412 while ($urow = sqlFetchArray($ures)) {
413 $uname = $urow['organization'];
414 if (empty($uname) ||
substr($uname, 0, 1) == '(') {
415 $uname = $urow['lname'];
416 if ($urow['fname']) $uname .= ", " . $urow['fname'];
418 $optionValue = htmlspecialchars( $urow['id'], ENT_QUOTES
);
419 $optionLabel = htmlspecialchars( $uname, ENT_NOQUOTES
);
420 echo "<option value='$optionValue'";
421 $title = $urow['username'] ?
xl('Local') : xl('External');
422 $optionTitle = htmlspecialchars( $title, ENT_QUOTES
);
423 echo " title='$optionTitle'";
424 if ($urow['id'] == $currvalue) echo " selected";
425 echo ">$optionLabel</option>";
431 else if ($data_type == 15) {
432 $fldlength = htmlspecialchars( $frow['fld_length'], ENT_QUOTES
);
433 $maxlength = $frow['max_length'];
434 $string_maxlength = "";
435 // if max_length is set to zero, then do not set a maxlength
436 if ($maxlength) $string_maxlength = "maxlength='".attr($maxlength)."'";
437 echo "<input type='text'" .
438 " name='form_$field_id_esc'" .
439 " id='form_related_code'" .
440 " size='$fldlength'" .
441 " $string_maxlength" .
442 " title='$description'" .
443 " value='$currescaped'" .
444 " onclick='sel_related(this)' readonly" .
448 // insurance company list
449 else if ($data_type == 16) {
450 echo "<select name='form_$field_id_esc' id='form_$field_id_esc' title='$description'>";
451 echo "<option value='0'></option>";
452 $insprovs = getInsuranceProviders();
453 $got_selected = false;
454 foreach ($insprovs as $key => $ipname) {
455 $optionValue = htmlspecialchars($key, ENT_QUOTES
);
456 $optionLabel = htmlspecialchars($ipname, ENT_NOQUOTES
);
457 echo "<option value='$optionValue'";
458 if ($currvalue == $key) {
460 $got_selected = true;
462 echo ">$optionLabel</option>";
464 if (!$got_selected && strlen($currvalue) > 0) {
465 echo "<option value='" . attr($currvalue) . "' selected>* " . text($currvalue) . " *</option>";
467 echo " <font color='red' title='" . xla('Please choose a valid selection from the list.') . "'>" . xlt('Fix this') . "!</font>";
475 else if ($data_type == 17) {
476 echo "<select name='form_$field_id_esc' id='form_$field_id_esc' title='$description'>";
477 echo "<option value='0'></option>";
478 $got_selected = false;
479 foreach ($ISSUE_TYPES as $key => $value) {
480 $optionValue = htmlspecialchars($key, ENT_QUOTES
);
481 $optionLabel = htmlspecialchars($value[1], ENT_NOQUOTES
);
482 echo "<option value='$optionValue'";
483 if ($currvalue == $key) {
485 $got_selected = true;
487 echo ">$optionLabel</option>";
489 if (!$got_selected && strlen($currvalue) > 0) {
490 echo "<option value='" . attr($currvalue) . "' selected>* " . text($currvalue) . " *</option>";
492 echo " <font color='red' title='" . xla('Please choose a valid selection from the list.') . "'>" . xlt('Fix this') . "!</font>";
499 // a set of labeled checkboxes
500 else if ($data_type == 21) {
501 // In this special case, fld_length is the number of columns generated.
502 $cols = max(1, $frow['fld_length']);
503 $avalue = explode('|', $currvalue);
504 $lres = sqlStatement("SELECT * FROM list_options " .
505 "WHERE list_id = ? ORDER BY seq, title", array($list_id) );
506 echo "<table cellpadding='0' cellspacing='0' width='100%'>";
507 $tdpct = (int) (100 / $cols);
508 for ($count = 0; $lrow = sqlFetchArray($lres); ++
$count) {
509 $option_id = $lrow['option_id'];
510 $option_id_esc = htmlspecialchars( $option_id, ENT_QUOTES
);
511 // if ($count) echo "<br />";
512 if ($count %
$cols == 0) {
513 if ($count) echo "</tr>";
516 echo "<td width='$tdpct%'>";
517 echo "<input type='checkbox' name='form_{$field_id_esc}[$option_id_esc]' id='form_{$field_id_esc}[$option_id_esc]' value='1'";
518 if (in_array($option_id, $avalue)) echo " checked";
520 // Added 5-09 by BM - Translate label if applicable
521 echo ">" . htmlspecialchars( xl_list_label($lrow['title']), ENT_NOQUOTES
);
527 if ($count > $cols) {
528 // Add some space after multiple rows of checkboxes.
529 $cols = htmlspecialchars( $cols, ENT_QUOTES
);
530 echo "<tr><td colspan='$cols' style='height:0.7em'></td></tr>";
536 // a set of labeled text input fields
537 else if ($data_type == 22) {
538 $tmp = explode('|', $currvalue);
540 foreach ($tmp as $value) {
541 if (preg_match('/^([^:]+):(.*)$/', $value, $matches)) {
542 $avalue[$matches[1]] = $matches[2];
545 $lres = sqlStatement("SELECT * FROM list_options " .
546 "WHERE list_id = ? ORDER BY seq, title", array($list_id) );
547 echo "<table cellpadding='0' cellspacing='0'>";
548 while ($lrow = sqlFetchArray($lres)) {
549 $option_id = $lrow['option_id'];
550 $option_id_esc = htmlspecialchars( $option_id, ENT_QUOTES
);
551 $maxlength = $frow['max_length'];
552 $string_maxlength = "";
553 // if max_length is set to zero, then do not set a maxlength
554 if ($maxlength) $string_maxlength = "maxlength='".attr($maxlength)."'";
555 $fldlength = empty($frow['fld_length']) ?
20 : $frow['fld_length'];
557 // Added 5-09 by BM - Translate label if applicable
558 echo "<tr><td>" . htmlspecialchars( xl_list_label($lrow['title']), ENT_NOQUOTES
) . " </td>";
559 $fldlength = htmlspecialchars( $fldlength, ENT_QUOTES
);
560 $optionValue = htmlspecialchars( $avalue[$option_id], ENT_QUOTES
);
561 echo "<td><input type='text'" .
562 " name='form_{$field_id_esc}[$option_id_esc]'" .
563 " id='form_{$field_id_esc}[$option_id_esc]'" .
564 " size='$fldlength'" .
565 " $string_maxlength" .
566 " value='$optionValue'";
567 echo " /></td></tr>";
572 // a set of exam results; 3 radio buttons and a text field:
573 else if ($data_type == 23) {
574 $tmp = explode('|', $currvalue);
576 foreach ($tmp as $value) {
577 if (preg_match('/^([^:]+):(.*)$/', $value, $matches)) {
578 $avalue[$matches[1]] = $matches[2];
581 $maxlength = $frow['max_length'];
582 $string_maxlength = "";
583 // if max_length is set to zero, then do not set a maxlength
584 if ($maxlength) $string_maxlength = "maxlength='".attr($maxlength)."'";
585 $fldlength = empty($frow['fld_length']) ?
20 : $frow['fld_length'];
586 $lres = sqlStatement("SELECT * FROM list_options " .
587 "WHERE list_id = ? ORDER BY seq, title", array($list_id) );
588 echo "<table cellpadding='0' cellspacing='0'>";
589 echo "<tr><td> </td><td class='bold'>" .
590 htmlspecialchars( xl('N/A'), ENT_NOQUOTES
) .
591 " </td><td class='bold'>" .
592 htmlspecialchars( xl('Nor'), ENT_NOQUOTES
) . " </td>" .
593 "<td class='bold'>" .
594 htmlspecialchars( xl('Abn'), ENT_NOQUOTES
) . " </td><td class='bold'>" .
595 htmlspecialchars( xl('Date/Notes'), ENT_NOQUOTES
) . "</td></tr>";
596 while ($lrow = sqlFetchArray($lres)) {
597 $option_id = $lrow['option_id'];
598 $option_id_esc = htmlspecialchars( $option_id, ENT_QUOTES
);
599 $restype = substr($avalue[$option_id], 0, 1);
600 $resnote = substr($avalue[$option_id], 2);
602 // Added 5-09 by BM - Translate label if applicable
603 echo "<tr><td>" . htmlspecialchars( xl_list_label($lrow['title']), ENT_NOQUOTES
) . " </td>";
605 for ($i = 0; $i < 3; ++
$i) {
606 $inputValue = htmlspecialchars( $i, ENT_QUOTES
);
607 echo "<td><input type='radio'" .
608 " name='radio_{$field_id_esc}[$option_id_esc]'" .
609 " id='radio_{$field_id_esc}[$option_id_esc]'" .
610 " value='$inputValue'";
611 if ($restype === "$i") echo " checked";
614 $fldlength = htmlspecialchars( $fldlength, ENT_QUOTES
);
615 $resnote = htmlspecialchars( $resnote, ENT_QUOTES
);
616 echo "<td><input type='text'" .
617 " name='form_{$field_id_esc}[$option_id_esc]'" .
618 " id='form_{$field_id_esc}[$option_id_esc]'" .
619 " size='$fldlength'" .
620 " $string_maxlength" .
621 " value='$resnote' /></td>";
627 // the list of active allergies for the current patient
628 // this is read-only!
629 else if ($data_type == 24) {
630 $query = "SELECT title, comments FROM lists WHERE " .
631 "pid = ? AND type = 'allergy' AND enddate IS NULL " .
633 // echo "<!-- $query -->\n"; // debugging
634 $lres = sqlStatement($query, array($GLOBALS['pid']));
636 while ($lrow = sqlFetchArray($lres)) {
637 if ($count++
) echo "<br />";
638 echo htmlspecialchars( $lrow['title'], ENT_NOQUOTES
);
639 if ($lrow['comments']) echo ' (' . htmlspecialchars( $lrow['comments'], ENT_NOQUOTES
) . ')';
643 // a set of labeled checkboxes, each with a text field:
644 else if ($data_type == 25) {
645 $tmp = explode('|', $currvalue);
647 foreach ($tmp as $value) {
648 if (preg_match('/^([^:]+):(.*)$/', $value, $matches)) {
649 $avalue[$matches[1]] = $matches[2];
652 $maxlength = $frow['max_length'];
653 $string_maxlength = "";
654 // if max_length is set to zero, then do not set a maxlength
655 if ($maxlength) $string_maxlength = "maxlength='".attr($maxlength)."'";
656 $fldlength = empty($frow['fld_length']) ?
20 : $frow['fld_length'];
657 $lres = sqlStatement("SELECT * FROM list_options " .
658 "WHERE list_id = ? ORDER BY seq, title", array($list_id) );
659 echo "<table cellpadding='0' cellspacing='0'>";
660 while ($lrow = sqlFetchArray($lres)) {
661 $option_id = $lrow['option_id'];
662 $option_id_esc = htmlspecialchars( $option_id, ENT_QUOTES
);
663 $restype = substr($avalue[$option_id], 0, 1);
664 $resnote = substr($avalue[$option_id], 2);
666 // Added 5-09 by BM - Translate label if applicable
667 echo "<tr><td>" . htmlspecialchars( xl_list_label($lrow['title']), ENT_NOQUOTES
) . " </td>";
669 $option_id = htmlspecialchars( $option_id, ENT_QUOTES
);
670 echo "<td><input type='checkbox' name='check_{$field_id_esc}[$option_id_esc]' id='check_{$field_id_esc}[$option_id_esc]' value='1'";
671 if ($restype) echo " checked";
672 echo " /> </td>";
673 $fldlength = htmlspecialchars( $fldlength, ENT_QUOTES
);
674 $resnote = htmlspecialchars( $resnote, ENT_QUOTES
);
675 echo "<td><input type='text'" .
676 " name='form_{$field_id_esc}[$option_id_esc]'" .
677 " id='form_{$field_id_esc}[$option_id_esc]'" .
678 " size='$fldlength'" .
679 " $string_maxlength" .
680 " value='$resnote' /></td>";
686 // single-selection list with ability to add to it
687 else if ($data_type == 26) {
688 echo generate_select_list("form_$field_id", $list_id, $currvalue,
689 $description, $showEmpty ?
$empty_title : '', 'addtolistclass_'.$list_id, $onchange, '', null, false, $backup_list);
691 // show the add button if user has access to correct list
692 $inputValue = htmlspecialchars( xl('Add'), ENT_QUOTES
);
693 $outputAddButton = "<input type='button' id='addtolistid_".$list_id_esc."' fieldid='form_".$field_id_esc."' class='addtolist' value='$inputValue'>";
694 if (aco_exist('lists', $list_id)) {
695 // a specific aco exist for this list, so ensure access
696 if (acl_check('lists', $list_id)) echo $outputAddButton;
699 // no specific aco exist for this list, so check for access to 'default' list
700 if (acl_check('lists', 'default')) echo $outputAddButton;
704 // a set of labeled radio buttons
705 else if ($data_type == 27) {
706 // In this special case, fld_length is the number of columns generated.
707 $cols = max(1, $frow['fld_length']);
708 $lres = sqlStatement("SELECT * FROM list_options " .
709 "WHERE list_id = ? ORDER BY seq, title", array($list_id) );
710 echo "<table cellpadding='0' cellspacing='0' width='100%'>";
711 $tdpct = (int) (100 / $cols);
712 $got_selected = FALSE;
713 for ($count = 0; $lrow = sqlFetchArray($lres); ++
$count) {
714 $option_id = $lrow['option_id'];
715 $option_id_esc = htmlspecialchars( $option_id, ENT_QUOTES
);
716 if ($count %
$cols == 0) {
717 if ($count) echo "</tr>";
720 echo "<td width='$tdpct%'>";
721 echo "<input type='radio' name='form_{$field_id_esc}' id='form_{$field_id_esc}[$option_id_esc]' value='$option_id_esc'";
722 if ((strlen($currvalue) == 0 && $lrow['is_default']) ||
723 (strlen($currvalue) > 0 && $option_id == $currvalue))
726 $got_selected = TRUE;
728 echo ">" . htmlspecialchars( xl_list_label($lrow['title']), ENT_NOQUOTES
);
733 if ($count > $cols) {
734 // Add some space after multiple rows of radio buttons.
735 $cols = htmlspecialchars( $cols, ENT_QUOTES
);
736 echo "<tr><td colspan='$cols' style='height:0.7em'></td></tr>";
740 if (!$got_selected && strlen($currvalue) > 0) {
741 $fontTitle = htmlspecialchars( xl('Please choose a valid selection.'), ENT_QUOTES
);
742 $fontText = htmlspecialchars( xl('Fix this'), ENT_NOQUOTES
);
743 echo "$currescaped <font color='red' title='$fontTitle'>$fontText!</font>";
747 // special case for history of lifestyle status; 3 radio buttons and a date text field:
748 // VicarePlus :: A selection list box for smoking status:
749 else if ($data_type == 28 ||
$data_type == 32) {
750 $tmp = explode('|', $currvalue);
751 switch(count($tmp)) {
770 $resdate = $restype = "";
773 $restype = $resdate = $resnote = "";
776 $maxlength = $frow['max_length'];
777 $string_maxlength = "";
778 // if max_length is set to zero, then do not set a maxlength
779 if ($maxlength) $string_maxlength = "maxlength='".attr($maxlength)."'";
780 $fldlength = empty($frow['fld_length']) ?
20 : $frow['fld_length'];
782 $fldlength = htmlspecialchars( $fldlength, ENT_QUOTES
);
783 $resnote = htmlspecialchars( $resnote, ENT_QUOTES
);
784 $resdate = htmlspecialchars( $resdate, ENT_QUOTES
);
785 echo "<table cellpadding='0' cellspacing='0'>";
787 if ($data_type == 28)
790 echo "<td><input type='text'" .
791 " name='form_$field_id_esc'" .
792 " id='form_$field_id_esc'" .
793 " size='$fldlength'" .
794 " $string_maxlength" .
795 " value='$resnote' /> </td>";
796 echo "<td class='bold'> ".
797 " ".
798 htmlspecialchars( xl('Status'), ENT_NOQUOTES
).": </td>";
800 else if($data_type == 32)
803 echo "<tr><td><input type='text'" .
804 " name='form_text_$field_id_esc'" .
805 " id='form_text_$field_id_esc'" .
806 " size='$fldlength'" .
807 " $string_maxlength" .
808 " value='$resnote' /> </td></tr>";
810 //Selection list for smoking status
811 $onchange = 'radioChange(this.options[this.selectedIndex].value)';//VicarePlus :: The javascript function for selection list.
812 echo generate_select_list("form_$field_id", $list_id, $reslist,
813 $description, $showEmpty ?
$empty_title : '', '', $onchange)."</td>";
814 echo "<td class='bold'> ".htmlspecialchars( xl('Status'), ENT_NOQUOTES
).": </td>";
817 echo "<td><input type='radio'" .
818 " name='radio_{$field_id_esc}'" .
819 " id='radio_{$field_id_esc}[current]'" .
820 " value='current".$field_id_esc."'";
821 if ($restype == "current".$field_id) echo " checked";
822 echo " if($data_type == 32) { onClick='smoking_statusClicked(this)' } />".htmlspecialchars( xl('Current'), ENT_NOQUOTES
)." </td>";
824 echo "<td><input type='radio'" .
825 " name='radio_{$field_id_esc}'" .
826 " id='radio_{$field_id_esc}[quit]'" .
827 " value='quit".$field_id_esc."'";
828 if ($restype == "quit".$field_id) echo " checked";
829 echo " if($data_type == 32) { onClick='smoking_statusClicked(this)' } />".htmlspecialchars( xl('Quit'), ENT_NOQUOTES
)." </td>";
831 echo "<td><input type='text' size='6' name='date_$field_id_esc' id='date_$field_id_esc'" .
832 " value='$resdate'" .
833 " title='$description'" .
834 " onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)' />" .
835 "<img src='$rootdir/pic/show_calendar.gif' align='absbottom' width='24' height='22'" .
836 " id='img_$field_id_esc' border='0' alt='[?]' style='cursor:pointer'" .
837 " title='" . htmlspecialchars( xl('Click here to choose a date'), ENT_QUOTES
) . "' /> </td>";
838 $date_init .= " Calendar.setup({inputField:'date_$field_id', ifFormat:'%Y-%m-%d', button:'img_$field_id'});\n";
840 echo "<td><input type='radio'" .
841 " name='radio_{$field_id_esc}'" .
842 " id='radio_{$field_id_esc}[never]'" .
843 " value='never".$field_id_esc."'";
844 if ($restype == "never".$field_id) echo " checked";
845 echo " if($data_type == 32) { onClick='smoking_statusClicked(this)' } />".htmlspecialchars( xl('Never'), ENT_NOQUOTES
)." </td>";
847 echo "<td><input type='radio'" .
848 " name='radio_{$field_id}'" .
849 " id='radio_{$field_id}[not_applicable]'" .
850 " value='not_applicable".$field_id."'";
851 if ($restype == "not_applicable".$field_id) echo " checked";
852 echo " if($data_type == 32) { onClick='smoking_statusClicked(this)' } />".htmlspecialchars( xl('N/A'), ENT_QUOTES
)." </td>";
857 // static text. read-only, of course.
858 else if ($data_type == 31) {
859 echo nl2br($frow['description']);
863 // Race and Ethnicity. After added support for backup lists, this is now the same as datatype 1; so have migrated it there.
866 else if($data_type == 34){
867 $arr = explode("|*|*|*|",$currvalue);
868 echo "<a href='../../../library/custom_template/custom_template.php?type=form_{$field_id}&contextName=".htmlspecialchars($list_id_esc,ENT_QUOTES
)."' class='iframe_medium' style='text-decoration:none;color:black;'>";
869 echo "<div id='form_{$field_id}_div' class='text-area'>".htmlspecialchars($arr[0],ENT_QUOTES
)."</div>";
870 echo "<div style='display:none'><textarea name='form_{$field_id}' id='form_{$field_id}' stye='display:none'>".$currvalue."</textarea></div>";
874 //facilities drop-down list
875 else if ($data_type == 35) {
876 if (empty($currvalue)){
879 dropdown_facility($selected = $currvalue, $name = "form_$field_id_esc", $allow_unspecified = true, $allow_allfacilities = false);
883 // supports backup list
884 else if ($data_type == 36) {
885 echo generate_select_list("form_$field_id", $list_id, $currvalue,
886 $description, $showEmpty ?
$empty_title : '', '', $onchange, '', null, true, $backup_list);
891 function generate_print_field($frow, $currvalue) {
892 global $rootdir, $date_init, $ISSUE_TYPES;
894 $currescaped = htmlspecialchars($currvalue, ENT_QUOTES
);
896 $data_type = $frow['data_type'];
897 $field_id = $frow['field_id'];
898 $list_id = $frow['list_id'];
899 $fld_length = $frow['fld_length'];
900 $backup_list = $frow['list_backup_id'];
902 $description = htmlspecialchars(xl_layout_label($frow['description']), ENT_QUOTES
);
904 // Can pass $frow['empty_title'] with this variable, otherwise
905 // will default to 'Unassigned'.
906 // If it is 'SKIP' then an empty text title is completely skipped.
908 if (isset($frow['empty_title'])) {
909 if ($frow['empty_title'] == "SKIP") {
910 //do not display an 'empty' choice
912 $empty_title = "Unassigned";
915 $empty_title = $frow['empty_title'];
919 $empty_title = "Unassigned";
922 // generic single-selection list
923 // Supports backup lists.
924 if ($data_type == 1 ||
$data_type == 26 ||
$data_type == 33) {
925 if (empty($fld_length)) {
926 if ($list_id == 'titles') {
934 $lrow = sqlQuery("SELECT title FROM list_options " .
935 "WHERE list_id = ? AND option_id = ?", array($list_id,$currvalue));
936 $tmp = xl_list_label($lrow['title']);
937 if ($lrow == 0 && !empty($backup_list)) {
938 // since primary list did not map, try to map to backup list
939 $lrow = sqlQuery("SELECT title FROM list_options " .
940 "WHERE list_id = ? AND option_id = ?", array($backup_list,$currvalue));
941 $tmp = xl_list_label($lrow['title']);
943 if (empty($tmp)) $tmp = "($currvalue)";
945 /*****************************************************************
946 echo "<input type='text'" .
947 " size='$fld_length'" .
951 *****************************************************************/
956 $tmp = htmlspecialchars( $tmp, ENT_QUOTES
);
962 else if ($data_type == 2 ||
$data_type == 15) {
963 /*****************************************************************
964 echo "<input type='text'" .
965 " size='$fld_length'" .
966 " value='$currescaped'" .
969 *****************************************************************/
970 if ($currescaped === '') $currescaped = ' ';
974 // long or multi-line text field
975 else if ($data_type == 3) {
976 $fldlength = htmlspecialchars( $fld_length, ENT_QUOTES
);
977 $maxlength = htmlspecialchars( $frow['fld_rows'], ENT_QUOTES
);
979 " cols='$fldlength'" .
980 " rows='$maxlength'>" .
981 $currescaped . "</textarea>";
985 else if ($data_type == 4) {
986 /*****************************************************************
987 echo "<input type='text' size='10'" .
988 " value='$currescaped'" .
989 " title='$description'" .
992 *****************************************************************/
993 if ($currvalue === '') { $tmp = oeFormatShortDate(' '); }
994 else { $tmp = htmlspecialchars( oeFormatShortDate($currvalue), ENT_QUOTES
); }
999 else if ($data_type == 10 ||
$data_type == 11) {
1002 $urow = sqlQuery("SELECT fname, lname, specialty FROM users " .
1003 "WHERE id = ?", array($currvalue) );
1004 $tmp = ucwords($urow['fname'] . " " . $urow['lname']);
1005 if (empty($tmp)) $tmp = "($currvalue)";
1007 /*****************************************************************
1008 echo "<input type='text'" .
1009 " size='$fld_length'" .
1013 *****************************************************************/
1014 if ($tmp === '') { $tmp = ' '; }
1015 else { $tmp = htmlspecialchars( $tmp, ENT_QUOTES
); }
1020 else if ($data_type == 12) {
1023 $pres = get_pharmacies();
1024 while ($prow = sqlFetchArray($pres)) {
1026 if ($currvalue == $key) {
1027 $tmp = $prow['name'] . ' ' . $prow['area_code'] . '-' .
1028 $prow['prefix'] . '-' . $prow['number'] . ' / ' .
1029 $prow['line1'] . ' / ' . $prow['city'];
1032 if (empty($tmp)) $tmp = "($currvalue)";
1034 /*****************************************************************
1035 echo "<input type='text'" .
1036 " size='$fld_length'" .
1040 *****************************************************************/
1041 if ($tmp === '') { $tmp = ' '; }
1042 else { $tmp = htmlspecialchars( $tmp, ENT_QUOTES
); }
1047 else if ($data_type == 13) {
1050 $squads = acl_get_squads();
1052 foreach ($squads as $key => $value) {
1053 if ($currvalue == $key) {
1058 if (empty($tmp)) $tmp = "($currvalue)";
1060 /*****************************************************************
1061 echo "<input type='text'" .
1062 " size='$fld_length'" .
1066 *****************************************************************/
1067 if ($tmp === '') { $tmp = ' '; }
1068 else { $tmp = htmlspecialchars( $tmp, ENT_QUOTES
); }
1073 else if ($data_type == 14) {
1076 $urow = sqlQuery("SELECT fname, lname, specialty FROM users " .
1077 "WHERE id = ?", array($currvalue) );
1078 $uname = $urow['lname'];
1079 if ($urow['fname']) $uname .= ", " . $urow['fname'];
1081 if (empty($tmp)) $tmp = "($currvalue)";
1083 /*****************************************************************
1084 echo "<input type='text'" .
1085 " size='$fld_length'" .
1089 *****************************************************************/
1090 if ($tmp === '') { $tmp = ' '; }
1091 else { $tmp = htmlspecialchars( $tmp, ENT_QUOTES
); }
1095 // insurance company list
1096 else if ($data_type == 16) {
1099 $insprovs = getInsuranceProviders();
1100 foreach ($insprovs as $key => $ipname) {
1101 if ($currvalue == $key) {
1105 if (empty($tmp)) $tmp = "($currvalue)";
1107 if ($tmp === '') $tmp = ' ';
1108 else $tmp = htmlspecialchars($tmp, ENT_QUOTES
);
1113 else if ($data_type == 17) {
1116 foreach ($ISSUE_TYPES as $key => $value) {
1117 if ($currvalue == $key) {
1121 if (empty($tmp)) $tmp = "($currvalue)";
1123 if ($tmp === '') $tmp = ' ';
1124 else $tmp = htmlspecialchars($tmp, ENT_QUOTES
);
1128 // a set of labeled checkboxes
1129 else if ($data_type == 21) {
1130 // In this special case, fld_length is the number of columns generated.
1131 $cols = max(1, $fld_length);
1132 $avalue = explode('|', $currvalue);
1133 $lres = sqlStatement("SELECT * FROM list_options " .
1134 "WHERE list_id = ? ORDER BY seq, title", array($list_id) );
1135 echo "<table cellpadding='0' cellspacing='0' width='100%'>";
1136 $tdpct = (int) (100 / $cols);
1137 for ($count = 0; $lrow = sqlFetchArray($lres); ++
$count) {
1138 $option_id = $lrow['option_id'];
1139 if ($count %
$cols == 0) {
1140 if ($count) echo "</tr>";
1143 echo "<td width='$tdpct%'>";
1144 echo "<input type='checkbox'";
1145 if (in_array($option_id, $avalue)) echo " checked";
1146 echo ">" . htmlspecialchars( xl_list_label($lrow['title']), ENT_NOQUOTES
);
1151 if ($count > $cols) {
1152 // Add some space after multiple rows of checkboxes.
1153 $cols = htmlspecialchars( $cols, ENT_QUOTES
);
1154 echo "<tr><td colspan='$cols' style='height:0.7em'></td></tr>";
1160 // a set of labeled text input fields
1161 else if ($data_type == 22) {
1162 $tmp = explode('|', $currvalue);
1164 foreach ($tmp as $value) {
1165 if (preg_match('/^([^:]+):(.*)$/', $value, $matches)) {
1166 $avalue[$matches[1]] = $matches[2];
1169 $lres = sqlStatement("SELECT * FROM list_options " .
1170 "WHERE list_id = ? ORDER BY seq, title", array($list_id) );
1171 echo "<table cellpadding='0' cellspacing='0'>";
1172 while ($lrow = sqlFetchArray($lres)) {
1173 $option_id = $lrow['option_id'];
1174 $fldlength = empty($fld_length) ?
20 : $fld_length;
1175 echo "<tr><td>" . htmlspecialchars( xl_list_label($lrow['title']), ENT_NOQUOTES
) . " </td>";
1176 $fldlength = htmlspecialchars( $fldlength, ENT_QUOTES
);
1177 $inputValue = htmlspecialchars( $avalue[$option_id], ENT_QUOTES
);
1178 echo "<td><input type='text'" .
1179 " size='$fldlength'" .
1180 " value='$inputValue'" .
1187 // a set of exam results; 3 radio buttons and a text field:
1188 else if ($data_type == 23) {
1189 $tmp = explode('|', $currvalue);
1191 foreach ($tmp as $value) {
1192 if (preg_match('/^([^:]+):(.*)$/', $value, $matches)) {
1193 $avalue[$matches[1]] = $matches[2];
1196 $fldlength = empty($fld_length) ?
20 : $fld_length;
1197 $lres = sqlStatement("SELECT * FROM list_options " .
1198 "WHERE list_id = ? ORDER BY seq, title", array($list_id) );
1199 echo "<table cellpadding='0' cellspacing='0'>";
1200 echo "<tr><td> </td><td class='bold'>" .
1201 htmlspecialchars( xl('N/A'), ENT_NOQUOTES
) .
1202 " </td><td class='bold'>" .
1203 htmlspecialchars( xl('Nor'), ENT_NOQUOTES
) . " </td>" .
1204 "<td class='bold'>" .
1205 htmlspecialchars( xl('Abn'), ENT_NOQUOTES
) . " </td><td class='bold'>" .
1206 htmlspecialchars( xl('Date/Notes'), ENT_NOQUOTES
) . "</td></tr>";
1207 while ($lrow = sqlFetchArray($lres)) {
1208 $option_id = $lrow['option_id'];
1209 $restype = substr($avalue[$option_id], 0, 1);
1210 $resnote = substr($avalue[$option_id], 2);
1211 echo "<tr><td>" . htmlspecialchars( xl_list_label($lrow['title']), ENT_NOQUOTES
) . " </td>";
1212 for ($i = 0; $i < 3; ++
$i) {
1213 echo "<td><input type='radio'";
1214 if ($restype === "$i") echo " checked";
1217 $resnote = htmlspecialchars( $resnote, ENT_QUOTES
);
1218 $fldlength = htmlspecialchars( $fldlength, ENT_QUOTES
);
1219 echo "<td><input type='text'" .
1220 " size='$fldlength'" .
1221 " value='$resnote'" .
1222 " class='under' /></td>" .
1228 // the list of active allergies for the current patient
1229 // this is read-only!
1230 else if ($data_type == 24) {
1231 $query = "SELECT title, comments FROM lists WHERE " .
1232 "pid = ? AND type = 'allergy' AND enddate IS NULL " .
1234 $lres = sqlStatement($query, array($GLOBALS['pid']) );
1236 while ($lrow = sqlFetchArray($lres)) {
1237 if ($count++
) echo "<br />";
1238 echo htmlspecialchars( $lrow['title'], ENT_QUOTES
);
1239 if ($lrow['comments']) echo htmlspecialchars( ' (' . $lrow['comments'] . ')', ENT_QUOTES
);
1243 // a set of labeled checkboxes, each with a text field:
1244 else if ($data_type == 25) {
1245 $tmp = explode('|', $currvalue);
1247 foreach ($tmp as $value) {
1248 if (preg_match('/^([^:]+):(.*)$/', $value, $matches)) {
1249 $avalue[$matches[1]] = $matches[2];
1252 $fldlength = empty($fld_length) ?
20 : $fld_length;
1253 $lres = sqlStatement("SELECT * FROM list_options " .
1254 "WHERE list_id = ? ORDER BY seq, title", array($list_id) );
1255 echo "<table cellpadding='0' cellspacing='0'>";
1256 while ($lrow = sqlFetchArray($lres)) {
1257 $option_id = $lrow['option_id'];
1258 $restype = substr($avalue[$option_id], 0, 1);
1259 $resnote = substr($avalue[$option_id], 2);
1260 echo "<tr><td>" . htmlspecialchars( xl_list_label($lrow['title']), ENT_NOQUOTES
) . " </td>";
1261 echo "<td><input type='checkbox'";
1262 if ($restype) echo " checked";
1263 echo " /> </td>";
1264 $fldlength = htmlspecialchars( $fldlength, ENT_QUOTES
);
1265 $resnote = htmlspecialchars( $resnote, ENT_QUOTES
);
1266 echo "<td><input type='text'" .
1267 " size='$fldlength'" .
1268 " value='$resnote'" .
1276 // a set of labeled radio buttons
1277 else if ($data_type == 27) {
1278 // In this special case, fld_length is the number of columns generated.
1279 $cols = max(1, $frow['fld_length']);
1280 $lres = sqlStatement("SELECT * FROM list_options " .
1281 "WHERE list_id = ? ORDER BY seq, title", array($list_id) );
1282 echo "<table cellpadding='0' cellspacing='0' width='100%'>";
1283 $tdpct = (int) (100 / $cols);
1284 for ($count = 0; $lrow = sqlFetchArray($lres); ++
$count) {
1285 $option_id = $lrow['option_id'];
1286 if ($count %
$cols == 0) {
1287 if ($count) echo "</tr>";
1290 echo "<td width='$tdpct%'>";
1291 echo "<input type='radio'";
1292 if ((strlen($currvalue) == 0 && $lrow['is_default']) ||
1293 (strlen($currvalue) > 0 && $option_id == $currvalue))
1297 echo ">" . htmlspecialchars( xl_list_label($lrow['title']), ENT_NOQUOTES
);
1302 if ($count > $cols) {
1303 // Add some space after multiple rows of radio buttons.
1304 $cols = htmlspecialchars( $cols, ENT_QUOTES
);
1305 echo "<tr><td colspan='$cols' style='height:0.7em'></td></tr>";
1311 // special case for history of lifestyle status; 3 radio buttons and a date text field:
1312 else if ($data_type == 28 ||
$data_type == 32) {
1313 $tmp = explode('|', $currvalue);
1314 switch(count($tmp)) {
1333 $resdate = $restype = "";
1336 $restype = $resdate = $resnote = "";
1339 $fldlength = empty($frow['fld_length']) ?
20 : $frow['fld_length'];
1340 echo "<table cellpadding='0' cellspacing='0'>";
1342 $fldlength = htmlspecialchars( $fldlength, ENT_QUOTES
);
1343 $resnote = htmlspecialchars( $resnote, ENT_QUOTES
);
1344 $resdate = htmlspecialchars( $resdate, ENT_QUOTES
);
1345 if($data_type == 28)
1347 echo "<td><input type='text'" .
1348 " size='$fldlength'" .
1350 " value='$resnote' /></td>";
1351 echo "<td class='bold'> ".
1352 " ".
1353 htmlspecialchars( xl('Status'), ENT_NOQUOTES
).": </td>";
1355 else if($data_type == 32)
1357 echo "<tr><td><input type='text'" .
1358 " size='$fldlength'" .
1360 " value='$resnote' /></td></tr>";
1362 $smoking_status_title = generate_display_field(array('data_type'=>'1','list_id'=>$list_id),$reslist);
1363 echo "<td><input type='text'" .
1364 " size='$fldlength'" .
1366 " value='$smoking_status_title' /></td>";
1367 echo "<td class='bold'> ".htmlspecialchars( xl('Status'), ENT_NOQUOTES
).": </td>";
1369 echo "<td><input type='radio'";
1370 if ($restype == "current".$field_id) echo " checked";
1371 echo "/>".htmlspecialchars( xl('Current'), ENT_NOQUOTES
)." </td>";
1373 echo "<td><input type='radio'";
1374 if ($restype == "current".$field_id) echo " checked";
1375 echo "/>".htmlspecialchars( xl('Quit'), ENT_NOQUOTES
)." </td>";
1377 echo "<td><input type='text' size='6'" .
1378 " value='$resdate'" .
1382 echo "<td><input type='radio'";
1383 if ($restype == "current".$field_id) echo " checked";
1384 echo " />".htmlspecialchars( xl('Never'), ENT_NOQUOTES
)."</td>";
1386 echo "<td><input type='radio'";
1387 if ($restype == "not_applicable".$field_id) echo " checked";
1388 echo " />".htmlspecialchars( xl('N/A'), ENT_NOQUOTES
)." </td>";
1393 // static text. read-only, of course.
1394 else if ($data_type == 31) {
1395 echo nl2br($frow['description']);
1398 else if($data_type == 34){
1399 echo "<a href='../../../library/custom_template/custom_template.php?type=form_{$field_id}&contextName=".htmlspecialchars($list_id_esc,ENT_QUOTES
)."' class='iframe_medium' style='text-decoration:none;color:black;'>";
1400 echo "<div id='form_{$field_id}_div' class='text-area'></div>";
1401 echo "<div style='display:none'><textarea name='form_{$field_id}' id='form_{$field_id}' stye='display:none'></textarea></div>";
1405 //facilities drop-down list
1406 else if ($data_type == 35) {
1407 if (empty($currvalue)){
1410 dropdown_facility($selected = $currvalue, $name = "form_$field_id_esc", $allow_unspecified = true, $allow_allfacilities = false);
1414 // Supports backup lists.
1415 else if ($data_type == 36) {
1416 if (empty($fld_length)) {
1417 if ($list_id == 'titles') {
1425 $values_array = explode("|", $currvalue);
1428 foreach($values_array as $value) {
1430 $lrow = sqlQuery("SELECT title FROM list_options " .
1431 "WHERE list_id = ? AND option_id = ?", array($list_id,$value));
1432 $tmp = xl_list_label($lrow['title']);
1433 if ($lrow == 0 && !empty($backup_list)) {
1434 // since primary list did not map, try to map to backup list
1435 $lrow = sqlQuery("SELECT title FROM list_options " .
1436 "WHERE list_id = ? AND option_id = ?", array($backup_list,$currvalue));
1437 $tmp = xl_list_label($lrow['title']);
1439 if (empty($tmp)) $tmp = "($value)";
1446 $tmp = htmlspecialchars( $tmp, ENT_QUOTES
);
1448 if ($i != 0 && $tmp != ' ') echo ",";
1456 function generate_display_field($frow, $currvalue) {
1457 global $ISSUE_TYPES;
1459 $data_type = $frow['data_type'];
1460 $field_id = isset($frow['field_id']) ?
$frow['field_id'] : null;
1461 $list_id = $frow['list_id'];
1462 $backup_list = $frow['list_backup_id'];
1466 // generic selection list or the generic selection list with add on the fly
1467 // feature, or radio buttons
1468 // Supports backup lists for datatypes 1,26,33
1469 if ($data_type == 1 ||
$data_type == 26 ||
$data_type == 27 ||
$data_type == 33) {
1470 $lrow = sqlQuery("SELECT title FROM list_options " .
1471 "WHERE list_id = ? AND option_id = ?", array($list_id,$currvalue) );
1472 $s = htmlspecialchars(xl_list_label($lrow['title']),ENT_NOQUOTES
);
1473 //if there is no matching value in the corresponding lists check backup list
1474 // only supported in data types 1,26,33
1475 if ($lrow == 0 && !empty($backup_list) && ($data_type == 1 ||
$data_type == 26 ||
$data_type == 33)) {
1476 $lrow = sqlQuery("SELECT title FROM list_options " .
1477 "WHERE list_id = ? AND option_id = ?", array($backup_list,$currvalue) );
1478 $s = htmlspecialchars(xl_list_label($lrow['title']),ENT_NOQUOTES
);
1482 // simple text field
1483 else if ($data_type == 2) {
1484 $s = htmlspecialchars($currvalue,ENT_NOQUOTES
);
1487 // long or multi-line text field
1488 else if ($data_type == 3) {
1489 $s = nl2br(htmlspecialchars($currvalue,ENT_NOQUOTES
));
1493 else if ($data_type == 4) {
1494 $s = htmlspecialchars(oeFormatShortDate($currvalue),ENT_NOQUOTES
);
1498 else if ($data_type == 10 ||
$data_type == 11) {
1499 $urow = sqlQuery("SELECT fname, lname, specialty FROM users " .
1500 "WHERE id = ?", array($currvalue) );
1501 $s = htmlspecialchars(ucwords($urow['fname'] . " " . $urow['lname']),ENT_NOQUOTES
);
1505 else if ($data_type == 12) {
1506 $pres = get_pharmacies();
1507 while ($prow = sqlFetchArray($pres)) {
1509 if ($currvalue == $key) {
1510 $s .= htmlspecialchars($prow['name'] . ' ' . $prow['area_code'] . '-' .
1511 $prow['prefix'] . '-' . $prow['number'] . ' / ' .
1512 $prow['line1'] . ' / ' . $prow['city'],ENT_NOQUOTES
);
1518 else if ($data_type == 13) {
1519 $squads = acl_get_squads();
1521 foreach ($squads as $key => $value) {
1522 if ($currvalue == $key) {
1523 $s .= htmlspecialchars($value[3],ENT_NOQUOTES
);
1530 else if ($data_type == 14) {
1531 $urow = sqlQuery("SELECT fname, lname, specialty FROM users " .
1532 "WHERE id = ?", array($currvalue));
1533 $uname = $urow['lname'];
1534 if ($urow['fname']) $uname .= ", " . $urow['fname'];
1535 $s = htmlspecialchars($uname,ENT_NOQUOTES
);
1539 else if ($data_type == 15) {
1540 $s = htmlspecialchars($currvalue,ENT_NOQUOTES
);
1543 // insurance company list
1544 else if ($data_type == 16) {
1545 $insprovs = getInsuranceProviders();
1546 foreach ($insprovs as $key => $ipname) {
1547 if ($currvalue == $key) {
1548 $s .= htmlspecialchars($ipname, ENT_NOQUOTES
);
1554 else if ($data_type == 17) {
1555 foreach ($ISSUE_TYPES as $key => $value) {
1556 if ($currvalue == $key) {
1557 $s .= htmlspecialchars($value[1], ENT_NOQUOTES
);
1562 // a set of labeled checkboxes
1563 else if ($data_type == 21) {
1564 $avalue = explode('|', $currvalue);
1565 $lres = sqlStatement("SELECT * FROM list_options " .
1566 "WHERE list_id = ? ORDER BY seq, title", array($list_id) );
1568 while ($lrow = sqlFetchArray($lres)) {
1569 $option_id = $lrow['option_id'];
1570 if (in_array($option_id, $avalue)) {
1571 if ($count++
) $s .= "<br />";
1573 // Added 5-09 by BM - Translate label if applicable
1574 $s .= htmlspecialchars(xl_list_label($lrow['title']),ENT_NOQUOTES
);
1580 // a set of labeled text input fields
1581 else if ($data_type == 22) {
1582 $tmp = explode('|', $currvalue);
1584 foreach ($tmp as $value) {
1585 if (preg_match('/^([^:]+):(.*)$/', $value, $matches)) {
1586 $avalue[$matches[1]] = $matches[2];
1589 $lres = sqlStatement("SELECT * FROM list_options " .
1590 "WHERE list_id = ? ORDER BY seq, title", array($list_id) );
1591 $s .= "<table cellpadding='0' cellspacing='0'>";
1592 while ($lrow = sqlFetchArray($lres)) {
1593 $option_id = $lrow['option_id'];
1594 if (empty($avalue[$option_id])) continue;
1596 // Added 5-09 by BM - Translate label if applicable
1597 $s .= "<tr><td class='bold' valign='top'>" . htmlspecialchars(xl_list_label($lrow['title']),ENT_NOQUOTES
) . ": </td>";
1599 $s .= "<td class='text' valign='top'>" . htmlspecialchars($avalue[$option_id],ENT_NOQUOTES
) . "</td></tr>";
1604 // a set of exam results; 3 radio buttons and a text field:
1605 else if ($data_type == 23) {
1606 $tmp = explode('|', $currvalue);
1608 foreach ($tmp as $value) {
1609 if (preg_match('/^([^:]+):(.*)$/', $value, $matches)) {
1610 $avalue[$matches[1]] = $matches[2];
1613 $lres = sqlStatement("SELECT * FROM list_options " .
1614 "WHERE list_id = ? ORDER BY seq, title", array($list_id) );
1615 $s .= "<table cellpadding='0' cellspacing='0'>";
1616 while ($lrow = sqlFetchArray($lres)) {
1617 $option_id = $lrow['option_id'];
1618 $restype = substr($avalue[$option_id], 0, 1);
1619 $resnote = substr($avalue[$option_id], 2);
1620 if (empty($restype) && empty($resnote)) continue;
1622 // Added 5-09 by BM - Translate label if applicable
1623 $s .= "<tr><td class='bold' valign='top'>" . htmlspecialchars(xl_list_label($lrow['title']),ENT_NOQUOTES
) . " </td>";
1625 $restype = ($restype == '1') ?
xl('Normal') : (($restype == '2') ?
xl('Abnormal') : xl('N/A'));
1626 // $s .= "<td class='text' valign='top'>$restype</td></tr>";
1627 // $s .= "<td class='text' valign='top'>$resnote</td></tr>";
1628 $s .= "<td class='text' valign='top'>" . htmlspecialchars($restype,ENT_NOQUOTES
) . " </td>";
1629 $s .= "<td class='text' valign='top'>" . htmlspecialchars($resnote,ENT_NOQUOTES
) . "</td>";
1635 // the list of active allergies for the current patient
1636 else if ($data_type == 24) {
1637 $query = "SELECT title, comments FROM lists WHERE " .
1638 "pid = ? AND type = 'allergy' AND enddate IS NULL " .
1640 // echo "<!-- $query -->\n"; // debugging
1641 $lres = sqlStatement($query, array($GLOBALS['pid']) );
1643 while ($lrow = sqlFetchArray($lres)) {
1644 if ($count++
) $s .= "<br />";
1645 $s .= htmlspecialchars($lrow['title'],ENT_NOQUOTES
);
1646 if ($lrow['comments']) $s .= ' (' . htmlspecialchars($lrow['comments'],ENT_NOQUOTES
) . ')';
1650 // a set of labeled checkboxes, each with a text field:
1651 else if ($data_type == 25) {
1652 $tmp = explode('|', $currvalue);
1654 foreach ($tmp as $value) {
1655 if (preg_match('/^([^:]+):(.*)$/', $value, $matches)) {
1656 $avalue[$matches[1]] = $matches[2];
1659 $lres = sqlStatement("SELECT * FROM list_options " .
1660 "WHERE list_id = ? ORDER BY seq, title", array($list_id) );
1661 $s .= "<table cellpadding='0' cellspacing='0'>";
1662 while ($lrow = sqlFetchArray($lres)) {
1663 $option_id = $lrow['option_id'];
1664 $restype = substr($avalue[$option_id], 0, 1);
1665 $resnote = substr($avalue[$option_id], 2);
1666 if (empty($restype) && empty($resnote)) continue;
1668 // Added 5-09 by BM - Translate label if applicable
1669 $s .= "<tr><td class='bold' valign='top'>" . htmlspecialchars(xl_list_label($lrow['title']),ENT_NOQUOTES
) . " </td>";
1671 $restype = $restype ?
xl('Yes') : xl('No');
1672 $s .= "<td class='text' valign='top'>" . htmlspecialchars($restype,ENT_NOQUOTES
) . "</td></tr>";
1673 $s .= "<td class='text' valign='top'>" . htmlspecialchars($resnote,ENT_NOQUOTES
) . "</td></tr>";
1679 // special case for history of lifestyle status; 3 radio buttons and a date text field:
1680 // VicarePlus :: A selection list for smoking status.
1681 else if ($data_type == 28 ||
$data_type == 32) {
1682 $tmp = explode('|', $currvalue);
1683 switch(count($tmp)) {
1702 $resdate = $restype = "";
1705 $restype = $resdate = $resnote = "";
1708 $s .= "<table cellpadding='0' cellspacing='0'>";
1712 if ($restype == "current".$field_id) $res = xl('Current');
1713 if ($restype == "quit".$field_id) $res = xl('Quit');
1714 if ($restype == "never".$field_id) $res = xl('Never');
1715 if ($restype == "not_applicable".$field_id) $res = xl('N/A');
1716 // $s .= "<td class='text' valign='top'>$restype</td></tr>";
1717 // $s .= "<td class='text' valign='top'>$resnote</td></tr>";
1718 if ($data_type == 28)
1720 if (!empty($resnote)) $s .= "<td class='text' valign='top'>" . htmlspecialchars($resnote,ENT_NOQUOTES
) . " </td>";
1722 //VicarePlus :: Tobacco field has a listbox, text box, date field and 3 radio buttons.
1723 else if ($data_type == 32)
1725 if (!empty($reslist)) $s .= "<td class='text' valign='top'>" . generate_display_field(array('data_type'=>'1','list_id'=>$list_id),$reslist) . " </td>";
1726 if (!empty($resnote)) $s .= "<td class='text' valign='top'>" . htmlspecialchars($resnote,ENT_NOQUOTES
) . " </td>";
1729 if (!empty($res)) $s .= "<td class='text' valign='top'><b>" . htmlspecialchars(xl('Status'),ENT_NOQUOTES
) . "</b>: " . htmlspecialchars($res,ENT_NOQUOTES
) . " </td>";
1730 if ($restype == "quit".$field_id) $s .= "<td class='text' valign='top'>" . htmlspecialchars($resdate,ENT_NOQUOTES
) . " </td>";
1735 // static text. read-only, of course.
1736 else if ($data_type == 31) {
1737 $s .= nl2br($frow['description']);
1740 else if($data_type == 34){
1741 $arr = explode("|*|*|*|",$currvalue);
1742 for($i=0;$i<sizeof($arr);$i++
){
1748 else if ($data_type == 35) {
1749 $urow = sqlQuery("SELECT id, name FROM facility ".
1750 "WHERE id = ?", array($currvalue) );
1751 $s = htmlspecialchars($urow['name'],ENT_NOQUOTES
);
1755 // Supports backup lists
1756 else if ($data_type == 36) {
1757 $values_array = explode("|", $currvalue);
1760 foreach($values_array as $value) {
1761 $lrow = sqlQuery("SELECT title FROM list_options " .
1762 "WHERE list_id = ? AND option_id = ?", array($list_id,$value) );
1764 if ($lrow == 0 && !empty($backup_list)) {
1766 $lrow = sqlQuery("SELECT title FROM list_options " .
1767 "WHERE list_id = ? AND option_id = ?", array($backup_list,$value) );
1771 $s = $s . ", " . htmlspecialchars(xl_list_label($lrow['title']),ENT_NOQUOTES
);
1773 $s = htmlspecialchars(xl_list_label($lrow['title']),ENT_NOQUOTES
);
1783 // Generate plain text versions of selected LBF field types.
1784 // Currently used by interface/patient_file/download_template.php.
1785 // More field types might need to be supported here in the future.
1787 function generate_plaintext_field($frow, $currvalue) {
1788 global $ISSUE_TYPES;
1790 $data_type = $frow['data_type'];
1791 $field_id = isset($frow['field_id']) ?
$frow['field_id'] : null;
1792 $list_id = $frow['list_id'];
1793 $backup_list = $frow['backup_list'];
1796 // generic selection list or the generic selection list with add on the fly
1797 // feature, or radio buttons
1798 // Supports backup lists (for datatypes 1,26,33)
1799 if ($data_type == 1 ||
$data_type == 26 ||
$data_type == 27 ||
$data_type == 33) {
1800 $lrow = sqlQuery("SELECT title FROM list_options " .
1801 "WHERE list_id = ? AND option_id = ?", array($list_id,$currvalue) );
1802 $s = xl_list_label($lrow['title']);
1803 //if there is no matching value in the corresponding lists check backup list
1804 // only supported in data types 1,26,33
1805 if ($lrow == 0 && !empty($backup_list) && ($data_type == 1 ||
$data_type == 26 ||
$data_type == 33)) {
1806 $lrow = sqlQuery("SELECT title FROM list_options " .
1807 "WHERE list_id = ? AND option_id = ?", array($backup_list,$currvalue) );
1808 $s = xl_list_label($lrow['title']);
1812 // simple or long text field
1813 else if ($data_type == 2 ||
$data_type == 3 ||
$data_type == 15) {
1818 else if ($data_type == 4) {
1819 $s = oeFormatShortDate($currvalue);
1823 else if ($data_type == 10 ||
$data_type == 11) {
1824 $urow = sqlQuery("SELECT fname, lname, specialty FROM users " .
1825 "WHERE id = ?", array($currvalue) );
1826 $s = ucwords($urow['fname'] . " " . $urow['lname']);
1830 else if ($data_type == 12) {
1831 $pres = get_pharmacies();
1832 while ($prow = sqlFetchArray($pres)) {
1834 if ($currvalue == $key) {
1835 $s .= $prow['name'] . ' ' . $prow['area_code'] . '-' .
1836 $prow['prefix'] . '-' . $prow['number'] . ' / ' .
1837 $prow['line1'] . ' / ' . $prow['city'];
1843 else if ($data_type == 14) {
1844 $urow = sqlQuery("SELECT fname, lname, specialty FROM users " .
1845 "WHERE id = ?", array($currvalue));
1846 $uname = $urow['lname'];
1847 if ($urow['fname']) $uname .= ", " . $urow['fname'];
1851 // insurance company list
1852 else if ($data_type == 16) {
1853 $insprovs = getInsuranceProviders();
1854 foreach ($insprovs as $key => $ipname) {
1855 if ($currvalue == $key) {
1861 // insurance company list
1862 else if ($data_type == 17) {
1863 foreach ($ISSUE_TYPES as $key => $value) {
1864 if ($currvalue == $key) {
1870 // a set of labeled checkboxes
1871 else if ($data_type == 21) {
1872 $avalue = explode('|', $currvalue);
1873 $lres = sqlStatement("SELECT * FROM list_options " .
1874 "WHERE list_id = ? ORDER BY seq, title", array($list_id) );
1876 while ($lrow = sqlFetchArray($lres)) {
1877 $option_id = $lrow['option_id'];
1878 if (in_array($option_id, $avalue)) {
1879 if ($count++
) $s .= "; ";
1880 $s .= xl_list_label($lrow['title']);
1885 // a set of labeled text input fields
1886 else if ($data_type == 22) {
1887 $tmp = explode('|', $currvalue);
1889 foreach ($tmp as $value) {
1890 if (preg_match('/^([^:]+):(.*)$/', $value, $matches)) {
1891 $avalue[$matches[1]] = $matches[2];
1894 $lres = sqlStatement("SELECT * FROM list_options " .
1895 "WHERE list_id = ? ORDER BY seq, title", array($list_id) );
1896 while ($lrow = sqlFetchArray($lres)) {
1897 $option_id = $lrow['option_id'];
1898 if (empty($avalue[$option_id])) continue;
1899 if ($s !== '') $s .= '; ';
1900 $s .= xl_list_label($lrow['title']) . ': ';
1901 $s .= $avalue[$option_id];
1905 // A set of exam results; 3 radio buttons and a text field.
1906 // This shows abnormal results only.
1907 else if ($data_type == 23) {
1908 $tmp = explode('|', $currvalue);
1910 foreach ($tmp as $value) {
1911 if (preg_match('/^([^:]+):(.*)$/', $value, $matches)) {
1912 $avalue[$matches[1]] = $matches[2];
1915 $lres = sqlStatement("SELECT * FROM list_options " .
1916 "WHERE list_id = ? ORDER BY seq, title", array($list_id) );
1917 while ($lrow = sqlFetchArray($lres)) {
1918 $option_id = $lrow['option_id'];
1919 $restype = substr($avalue[$option_id], 0, 1);
1920 $resnote = substr($avalue[$option_id], 2);
1921 if (empty($restype) && empty($resnote)) continue;
1922 if ($restype != '2') continue; // show abnormal results only
1923 if ($s !== '') $s .= '; ';
1924 $s .= xl_list_label($lrow['title']);
1925 if (!empty($resnote)) $s .= ': ' . $resnote;
1929 // the list of active allergies for the current patient
1930 else if ($data_type == 24) {
1931 $query = "SELECT title, comments FROM lists WHERE " .
1932 "pid = ? AND type = 'allergy' AND enddate IS NULL " .
1934 $lres = sqlStatement($query, array($GLOBALS['pid']));
1936 while ($lrow = sqlFetchArray($lres)) {
1937 if ($count++
) $s .= "; ";
1938 $s .= $lrow['title'];
1939 if ($lrow['comments']) $s .= ' (' . $lrow['comments'] . ')';
1943 // a set of labeled checkboxes, each with a text field:
1944 else if ($data_type == 25) {
1945 $tmp = explode('|', $currvalue);
1947 foreach ($tmp as $value) {
1948 if (preg_match('/^([^:]+):(.*)$/', $value, $matches)) {
1949 $avalue[$matches[1]] = $matches[2];
1952 $lres = sqlStatement("SELECT * FROM list_options " .
1953 "WHERE list_id = ? ORDER BY seq, title", array($list_id));
1954 while ($lrow = sqlFetchArray($lres)) {
1955 $option_id = $lrow['option_id'];
1956 $restype = substr($avalue[$option_id], 0, 1);
1957 $resnote = substr($avalue[$option_id], 2);
1958 if (empty($restype) && empty($resnote)) continue;
1959 if ($s !== '') $s .= '; ';
1960 $s .= xl_list_label($lrow['title']);
1961 $restype = $restype ?
xl('Yes') : xl('No');
1963 if ($resnote) $s .= ' ' . $resnote;
1967 // special case for history of lifestyle status; 3 radio buttons and a date text field:
1968 // VicarePlus :: A selection list for smoking status.
1969 else if ($data_type == 28 ||
$data_type == 32) {
1970 $tmp = explode('|', $currvalue);
1971 $resnote = count($tmp) > 0 ?
$tmp[0] : '';
1972 $restype = count($tmp) > 1 ?
$tmp[1] : '';
1973 $resdate = count($tmp) > 2 ?
$tmp[2] : '';
1974 $reslist = count($tmp) > 3 ?
$tmp[3] : '';
1976 if ($restype == "current" . $field_id) $res = xl('Current');
1977 if ($restype == "quit" . $field_id) $res = xl('Quit');
1978 if ($restype == "never" . $field_id) $res = xl('Never');
1979 if ($restype == "not_applicable". $field_id) $res = xl('N/A');
1981 if ($data_type == 28) {
1982 if (!empty($resnote)) $s .= $resnote;
1984 // Tobacco field has a listbox, text box, date field and 3 radio buttons.
1985 else if ($data_type == 32) {
1986 if (!empty($reslist)) $s .= generate_plaintext_field(array('data_type'=>'1','list_id'=>$list_id),$reslist);
1987 if (!empty($resnote)) $s .= ' ' . $resnote;
1990 if ($s !== '') $s .= ' ';
1991 $s .= xl('Status') . ' ' . $res;
1993 if ($restype == "quit".$field_id) {
1994 if ($s !== '') $s .= ' ';
2000 // Supports backup lists
2001 else if ($data_type == 36) {
2002 $values_array = explode("|", $currvalue);
2005 foreach($values_array as $value) {
2006 $lrow = sqlQuery("SELECT title FROM list_options " .
2007 "WHERE list_id = ? AND option_id = ?", array($list_id,$value) );
2009 if ($lrow == 0 && !empty($backup_list)) {
2011 $lrow = sqlQuery("SELECT title FROM list_options " .
2012 "WHERE list_id = ? AND option_id = ?", array($backup_list,$value) );
2016 $s = $s . ", " . xl_list_label($lrow['title']);
2018 $s = xl_list_label($lrow['title']);
2028 $CPR = 4; // cells per row of generic data
2033 function disp_end_cell() {
2034 global $item_count, $cell_count;
2035 if ($item_count > 0) {
2041 function disp_end_row() {
2042 global $cell_count, $CPR;
2044 if ($cell_count > 0) {
2045 for (; $cell_count < $CPR; ++
$cell_count) echo "<td></td>";
2051 function disp_end_group() {
2053 if (strlen($last_group) > 0) {
2058 function display_layout_rows($formtype, $result1, $result2='') {
2059 global $item_count, $cell_count, $last_group, $CPR;
2061 $fres = sqlStatement("SELECT * FROM layout_options " .
2062 "WHERE form_id = ? AND uor > 0 " .
2063 "ORDER BY group_name, seq", array($formtype) );
2065 while ($frow = sqlFetchArray($fres)) {
2066 $this_group = $frow['group_name'];
2067 $titlecols = $frow['titlecols'];
2068 $datacols = $frow['datacols'];
2069 $data_type = $frow['data_type'];
2070 $field_id = $frow['field_id'];
2071 $list_id = $frow['list_id'];
2074 if ($formtype == 'DEM') {
2075 if ($GLOBALS['athletic_team']) {
2076 // Skip fitness level and return-to-play date because those appear
2077 // in a special display/update form on this page.
2078 if ($field_id === 'fitness' ||
$field_id === 'userdate1') continue;
2080 if (strpos($field_id, 'em_') === 0) {
2081 // Skip employer related fields, if it's disabled.
2082 if ($GLOBALS['omit_employers']) continue;
2083 $tmp = substr($field_id, 3);
2084 if (isset($result2[$tmp])) $currvalue = $result2[$tmp];
2087 if (isset($result1[$field_id])) $currvalue = $result1[$field_id];
2091 if (isset($result1[$field_id])) $currvalue = $result1[$field_id];
2094 // Handle a data category (group) change.
2095 if (strcmp($this_group, $last_group) != 0) {
2096 $group_name = substr($this_group, 1);
2097 // totally skip generating the employer category, if it's disabled.
2098 if ($group_name === 'Employer' && $GLOBALS['omit_employers']) continue;
2100 $last_group = $this_group;
2103 // filter out all the empty field data from the patient report.
2104 if (!empty($currvalue) && !($currvalue == '0000-00-00 00:00:00')) {
2105 // Handle starting of a new row.
2106 if (($titlecols > 0 && $cell_count >= $CPR) ||
$cell_count == 0) {
2110 echo "<td class='groupname'>";
2111 //echo "<td class='groupname' style='padding-right:5pt' valign='top'>";
2112 //echo "<font color='#008800'>$group_name</font>";
2114 // Added 5-09 by BM - Translate label if applicable
2115 echo htmlspecialchars(xl_layout_label($group_name),ENT_NOQUOTES
);
2119 //echo "<td class='' style='padding-right:5pt' valign='top'>";
2120 echo "<td valign='top'> ";
2125 if ($item_count == 0 && $titlecols == 0) $titlecols = 1;
2127 // Handle starting of a new label cell.
2128 if ($titlecols > 0) {
2130 //echo "<td class='label' colspan='$titlecols' valign='top'";
2131 $titlecols_esc = htmlspecialchars( $titlecols, ENT_QUOTES
);
2132 echo "<td class='label' colspan='$titlecols_esc' ";
2133 //if ($cell_count == 2) echo " style='padding-left:10pt'";
2135 $cell_count +
= $titlecols;
2139 // Added 5-09 by BM - Translate label if applicable
2140 if ($frow['title']) echo htmlspecialchars(xl_layout_label($frow['title']).":",ENT_NOQUOTES
); else echo " ";
2142 // Handle starting of a new data cell.
2143 if ($datacols > 0) {
2145 //echo "<td class='text data' colspan='$datacols' valign='top'";
2146 $datacols_esc = htmlspecialchars( $datacols, ENT_QUOTES
);
2147 echo "<td class='text data' colspan='$datacols_esc'";
2148 //if ($cell_count > 0) echo " style='padding-left:5pt'";
2150 $cell_count +
= $datacols;
2154 echo generate_display_field($frow, $currvalue);
2161 function display_layout_tabs($formtype, $result1, $result2='') {
2162 global $item_count, $cell_count, $last_group, $CPR;
2164 $fres = sqlStatement("SELECT distinct group_name FROM layout_options " .
2165 "WHERE form_id = ? AND uor > 0 " .
2166 "ORDER BY group_name, seq", array($formtype) );
2169 while ($frow = sqlFetchArray($fres)) {
2170 $this_group = $frow['group_name'];
2171 $group_name = substr($this_group, 1);
2173 <li
<?php
echo $first ?
'class="current"' : '' ?
>>
2174 <a href
="/play/javascript-tabbed-navigation/" id
="header_tab_<?php echo ".htmlspecialchars($group_name,ENT_QUOTES
)."?>">
2175 <?php
echo htmlspecialchars(xl_layout_label($group_name),ENT_NOQUOTES
); ?
></a
>
2182 function display_layout_tabs_data($formtype, $result1, $result2='') {
2183 global $item_count, $cell_count, $last_group, $CPR;
2185 $fres = sqlStatement("SELECT distinct group_name FROM layout_options " .
2186 "WHERE form_id = ? AND uor > 0 " .
2187 "ORDER BY group_name, seq", array($formtype));
2190 while ($frow = sqlFetchArray($fres)) {
2191 $this_group = isset($frow['group_name']) ?
$frow['group_name'] : "" ;
2192 $titlecols = isset($frow['titlecols']) ?
$frow['titlecols'] : "";
2193 $datacols = isset($frow['datacols']) ?
$frow['datacols'] : "";
2194 $data_type = isset($frow['data_type']) ?
$frow['data_type'] : "";
2195 $field_id = isset($frow['field_id']) ?
$frow['field_id'] : "";
2196 $list_id = isset($frow['list_id']) ?
$frow['list_id'] : "";
2199 $group_fields_query = sqlStatement("SELECT * FROM layout_options " .
2200 "WHERE form_id = ? AND uor > 0 AND group_name = ? " .
2201 "ORDER BY seq", array($formtype, $this_group) );
2204 <div
class="tab <?php echo $first ? 'current' : '' ?>">
2205 <table border
='0' cellpadding
='0'>
2208 while ($group_fields = sqlFetchArray($group_fields_query)) {
2210 $titlecols = $group_fields['titlecols'];
2211 $datacols = $group_fields['datacols'];
2212 $data_type = $group_fields['data_type'];
2213 $field_id = $group_fields['field_id'];
2214 $list_id = $group_fields['list_id'];
2217 if ($formtype == 'DEM') {
2218 if ($GLOBALS['athletic_team']) {
2219 // Skip fitness level and return-to-play date because those appear
2220 // in a special display/update form on this page.
2221 if ($field_id === 'fitness' ||
$field_id === 'userdate1') continue;
2223 if (strpos($field_id, 'em_') === 0) {
2224 // Skip employer related fields, if it's disabled.
2225 if ($GLOBALS['omit_employers']) continue;
2226 $tmp = substr($field_id, 3);
2227 if (isset($result2[$tmp])) $currvalue = $result2[$tmp];
2230 if (isset($result1[$field_id])) $currvalue = $result1[$field_id];
2234 if (isset($result1[$field_id])) $currvalue = $result1[$field_id];
2237 // Handle a data category (group) change.
2238 if (strcmp($this_group, $last_group) != 0) {
2239 $group_name = substr($this_group, 1);
2240 // totally skip generating the employer category, if it's disabled.
2241 if ($group_name === 'Employer' && $GLOBALS['omit_employers']) continue;
2242 $last_group = $this_group;
2245 // Handle starting of a new row.
2246 if (($titlecols > 0 && $cell_count >= $CPR) ||
$cell_count == 0) {
2251 if ($item_count == 0 && $titlecols == 0) {
2255 // Handle starting of a new label cell.
2256 if ($titlecols > 0) {
2258 $titlecols_esc = htmlspecialchars( $titlecols, ENT_QUOTES
);
2259 echo "<td class='label' colspan='$titlecols_esc' ";
2261 $cell_count +
= $titlecols;
2265 // Added 5-09 by BM - Translate label if applicable
2266 if ($group_fields['title']) echo htmlspecialchars(xl_layout_label($group_fields['title']).":",ENT_NOQUOTES
); else echo " ";
2268 // Handle starting of a new data cell.
2269 if ($datacols > 0) {
2271 $datacols_esc = htmlspecialchars( $datacols, ENT_QUOTES
);
2272 echo "<td class='text data' colspan='$datacols_esc'";
2274 $cell_count +
= $datacols;
2278 echo generate_display_field($group_fields, $currvalue);
2295 function display_layout_tabs_data_editable($formtype, $result1, $result2='') {
2296 global $item_count, $cell_count, $last_group, $CPR;
2298 $fres = sqlStatement("SELECT distinct group_name FROM layout_options " .
2299 "WHERE form_id = ? AND uor > 0 " .
2300 "ORDER BY group_name, seq", array($formtype) );
2303 while ($frow = sqlFetchArray($fres)) {
2304 $this_group = $frow['group_name'];
2305 $group_name = substr($this_group, 1);
2306 $group_name_esc = htmlspecialchars( $group_name, ENT_QUOTES
);
2307 $titlecols = $frow['titlecols'];
2308 $datacols = $frow['datacols'];
2309 $data_type = $frow['data_type'];
2310 $field_id = $frow['field_id'];
2311 $list_id = $frow['list_id'];
2314 $group_fields_query = sqlStatement("SELECT * FROM layout_options " .
2315 "WHERE form_id = ? AND uor > 0 AND group_name = ? " .
2316 "ORDER BY seq", array($formtype,$this_group) );
2319 <div
class="tab <?php echo $first ? 'current' : '' ?>" id
="tab_<?php echo $group_name_esc?>" >
2320 <table border
='0' cellpadding
='0'>
2323 while ($group_fields = sqlFetchArray($group_fields_query)) {
2325 $titlecols = $group_fields['titlecols'];
2326 $datacols = $group_fields['datacols'];
2327 $data_type = $group_fields['data_type'];
2328 $field_id = $group_fields['field_id'];
2329 $list_id = $group_fields['list_id'];
2330 $backup_list = $group_fields['list_backup_id'];
2333 if ($formtype == 'DEM') {
2334 if ($GLOBALS['athletic_team']) {
2335 // Skip fitness level and return-to-play date because those appear
2336 // in a special display/update form on this page.
2337 if ($field_id === 'fitness' ||
$field_id === 'userdate1') continue;
2339 if (strpos($field_id, 'em_') === 0) {
2340 // Skip employer related fields, if it's disabled.
2341 if ($GLOBALS['omit_employers']) continue;
2342 $tmp = substr($field_id, 3);
2343 if (isset($result2[$tmp])) $currvalue = $result2[$tmp];
2346 if (isset($result1[$field_id])) $currvalue = $result1[$field_id];
2350 if (isset($result1[$field_id])) $currvalue = $result1[$field_id];
2353 // Handle a data category (group) change.
2354 if (strcmp($this_group, $last_group) != 0) {
2355 $group_name = substr($this_group, 1);
2356 // totally skip generating the employer category, if it's disabled.
2357 if ($group_name === 'Employer' && $GLOBALS['omit_employers']) continue;
2358 $last_group = $this_group;
2361 // Handle starting of a new row.
2362 if (($titlecols > 0 && $cell_count >= $CPR) ||
$cell_count == 0) {
2367 if ($item_count == 0 && $titlecols == 0) {
2371 // Handle starting of a new label cell.
2372 if ($titlecols > 0) {
2374 $titlecols_esc = htmlspecialchars( $titlecols, ENT_QUOTES
);
2375 echo "<td class='label' colspan='$titlecols_esc' ";
2377 $cell_count +
= $titlecols;
2381 // Added 5-09 by BM - Translate label if applicable
2382 if ($group_fields['title']) echo (htmlspecialchars( xl_layout_label($group_fields['title']), ENT_NOQUOTES
).":"); else echo " ";
2384 // Handle starting of a new data cell.
2385 if ($datacols > 0) {
2387 $datacols_esc = htmlspecialchars( $datacols, ENT_QUOTES
);
2388 echo "<td class='text data' colspan='$datacols_esc'";
2390 $cell_count +
= $datacols;
2395 echo generate_form_field($group_fields, $currvalue);
2409 // From the currently posted HTML form, this gets the value of the
2410 // field corresponding to the provided layout_options table row.
2412 function get_layout_form_value($frow, $prefix='form_') {
2413 // Bring in $sanitize_all_escapes variable, which will decide
2414 // the variable escaping method.
2415 global $sanitize_all_escapes;
2417 $maxlength = empty($frow['max_length']) ?
0 : intval($frow['max_length']);
2418 $data_type = $frow['data_type'];
2419 $field_id = $frow['field_id'];
2421 if (isset($_POST["$prefix$field_id"])) {
2422 if ($data_type == 21) {
2423 // $_POST["$prefix$field_id"] is an array of checkboxes and its keys
2424 // must be concatenated into a |-separated string.
2425 foreach ($_POST["$prefix$field_id"] as $key => $val) {
2426 if (strlen($value)) $value .= '|';
2430 else if ($data_type == 22) {
2431 // $_POST["$prefix$field_id"] is an array of text fields to be imploded
2432 // into "key:value|key:value|...".
2433 foreach ($_POST["$prefix$field_id"] as $key => $val) {
2434 $val = str_replace('|', ' ', $val);
2435 if (strlen($value)) $value .= '|';
2436 $value .= "$key:$val";
2439 else if ($data_type == 23) {
2440 // $_POST["$prefix$field_id"] is an array of text fields with companion
2441 // radio buttons to be imploded into "key:n:notes|key:n:notes|...".
2442 foreach ($_POST["$prefix$field_id"] as $key => $val) {
2443 $restype = $_POST["radio_{$field_id}"][$key];
2444 if (empty($restype)) $restype = '0';
2445 $val = str_replace('|', ' ', $val);
2446 if (strlen($value)) $value .= '|';
2447 $value .= "$key:$restype:$val";
2450 else if ($data_type == 25) {
2451 // $_POST["$prefix$field_id"] is an array of text fields with companion
2452 // checkboxes to be imploded into "key:n:notes|key:n:notes|...".
2453 foreach ($_POST["$prefix$field_id"] as $key => $val) {
2454 $restype = empty($_POST["check_{$field_id}"][$key]) ?
'0' : '1';
2455 $val = str_replace('|', ' ', $val);
2456 if (strlen($value)) $value .= '|';
2457 $value .= "$key:$restype:$val";
2460 else if ($data_type == 28 ||
$data_type == 32) {
2461 // $_POST["$prefix$field_id"] is an date text fields with companion
2462 // radio buttons to be imploded into "notes|type|date".
2463 $restype = $_POST["radio_{$field_id}"];
2464 if (empty($restype)) $restype = '0';
2465 $resdate = str_replace('|', ' ', $_POST["date_$field_id"]);
2466 $resnote = str_replace('|', ' ', $_POST["$prefix$field_id"]);
2467 if ($data_type == 32)
2469 //VicarePlus :: Smoking status data is imploded into "note|type|date|list".
2470 $reslist = str_replace('|', ' ', $_POST["$prefix$field_id"]);
2471 $res_text_note = str_replace('|', ' ', $_POST["{$prefix}text_$field_id"]);
2472 $value = "$res_text_note|$restype|$resdate|$reslist";
2475 $value = "$resnote|$restype|$resdate";
2477 else if ($data_type == 36) {
2478 $value_array = $_POST["form_$field_id"];
2480 foreach ($value_array as $key => $valueofkey) {
2482 $value = $valueofkey;
2484 $value = $value . "|" . $valueofkey;
2490 $value = $_POST["$prefix$field_id"];
2494 // Better to die than to silently truncate data!
2495 if ($maxlength && $maxlength != 0 && strlen($value) > $maxlength)
2496 die(htmlspecialchars( xl('ERROR: Field') . " '$field_id' " . xl('is too long'), ENT_NOQUOTES
) .
2497 ":<br /> <br />".htmlspecialchars( $value, ENT_NOQUOTES
));
2499 // Make sure the return value is quote-safe.
2500 if ($sanitize_all_escapes) {
2501 //escapes already removed and using binding/placemarks in sql calls
2502 // so only need to trim value
2503 return trim($value);
2506 //need to explicitly prepare value
2507 return formTrim($value);
2511 // Generate JavaScript validation logic for the required fields.
2513 function generate_layout_validation($form_id) {
2514 $fres = sqlStatement("SELECT * FROM layout_options " .
2515 "WHERE form_id = ? AND uor > 0 AND field_id != '' " .
2516 "ORDER BY group_name, seq", array($form_id) );
2518 while ($frow = sqlFetchArray($fres)) {
2519 if ($frow['uor'] < 2) continue;
2520 $data_type = $frow['data_type'];
2521 $field_id = $frow['field_id'];
2522 $fldtitle = $frow['title'];
2523 if (!$fldtitle) $fldtitle = $frow['description'];
2524 $fldname = htmlspecialchars( "form_$field_id", ENT_QUOTES
);
2525 switch($data_type) {
2535 " if (f.$fldname.selectedIndex <= 0) {\n" .
2536 " if (f.$fldname.focus) f.$fldname.focus();\n" .
2537 " errMsgs[errMsgs.length] = '" . htmlspecialchars( (xl_layout_label($fldtitle)), ENT_QUOTES
) . "'; \n" .
2540 case 27: // radio buttons
2543 " for (; i < f.$fldname.length; ++i) if (f.$fldname[i].checked) break;\n" .
2544 " if (i >= f.$fldname.length) {\n" .
2545 " errMsgs[errMsgs.length] = '" . htmlspecialchars( (xl_layout_label($fldtitle)), ENT_QUOTES
) . "'; \n" .
2553 " if (trimlen(f.$fldname.value) == 0) {\n" .
2554 " if (f.$fldname.focus) f.$fldname.focus();\n" .
2555 " $('#" . $fldname . "').parents('div.tab').each( function(){ var tabHeader = $('#header_' + $(this).attr('id') ); tabHeader.css('color','red'); } ); " .
2556 " $('#" . $fldname . "').attr('style','background:red'); \n" .
2557 " errMsgs[errMsgs.length] = '" . htmlspecialchars( (xl_layout_label($fldtitle)), ENT_QUOTES
) . "'; \n" .
2559 " $('#" . $fldname . "').attr('style',''); " .
2560 " $('#" . $fldname . "').parents('div.tab').each( function(){ var tabHeader = $('#header_' + $(this).attr('id') ); tabHeader.css('color',''); } ); " .
2568 * DROPDOWN FOR FACILITIES
2570 * build a dropdown with all facilities
2572 * @param string $selected - name of the currently selected facility
2573 * use '0' for "unspecified facility"
2574 * use '' for "All facilities" (the default)
2575 * @param string $name - the name/id for select form (defaults to "form_facility")
2576 * @param boolean $allow_unspecified - include an option for "unspecified" facility
2578 * @return void - just echo the html encoded string
2580 * Note: This should become a data-type at some point, according to Brady
2582 function dropdown_facility($selected = '', $name = 'form_facility', $allow_unspecified = true, $allow_allfacilities = true) {
2583 $have_selected = false;
2584 $query = "SELECT id, name FROM facility ORDER BY name";
2585 $fres = sqlStatement($query);
2587 $name = htmlspecialchars($name, ENT_QUOTES
);
2588 echo " <select name=\"$name\" id=\"$name\">\n";
2590 if ($allow_allfacilities) {
2592 $option_selected_attr = '';
2593 if ($selected == '') {
2594 $option_selected_attr = ' selected="selected"';
2595 $have_selected = true;
2597 $option_content = htmlspecialchars('-- ' . xl('All Facilities') . ' --', ENT_NOQUOTES
);
2598 echo " <option value=\"$option_value\" $option_selected_attr>$option_content</option>\n";
2599 } elseif ($allow_unspecified) {
2600 $option_value = '0';
2601 $option_selected_attr = '';
2602 if ( $selected == '0' ) {
2603 $option_selected_attr = ' selected="selected"';
2604 $have_selected = true;
2606 $option_content = htmlspecialchars('-- ' . xl('Unspecified') . ' --', ENT_NOQUOTES
);
2607 echo " <option value=\"$option_value\" $option_selected_attr>$option_content</option>\n";
2610 while ($frow = sqlFetchArray($fres)) {
2611 $facility_id = $frow['id'];
2612 $option_value = htmlspecialchars($facility_id, ENT_QUOTES
);
2613 $option_selected_attr = '';
2614 if ($selected == $facility_id) {
2615 $option_selected_attr = ' selected="selected"';
2616 $have_selected = true;
2618 $option_content = htmlspecialchars($frow['name'], ENT_NOQUOTES
);
2619 echo " <option value=\"$option_value\" $option_selected_attr>$option_content</option>\n";
2622 if ($allow_unspecified && $allow_allfacilities) {
2623 $option_value = '0';
2624 $option_selected_attr = '';
2625 if ( $selected == '0' ) {
2626 $option_selected_attr = ' selected="selected"';
2627 $have_selected = true;
2629 $option_content = htmlspecialchars('-- ' . xl('Unspecified') . ' --', ENT_NOQUOTES
);
2630 echo " <option value=\"$option_value\" $option_selected_attr>$option_content</option>\n";
2633 if (!$have_selected) {
2634 $option_value = htmlspecialchars($selected, ENT_QUOTES
);
2635 $option_label = htmlspecialchars('(' . xl('Do not change') . ')', ENT_QUOTES
);
2636 $option_content = htmlspecialchars(xl('Missing or Invalid'), ENT_NOQUOTES
);
2637 echo " <option value='$option_value' label='$option_label' selected='selected'>$option_content</option>\n";
2639 echo " </select>\n";
2642 // Expand Collapse Widget
2643 // This forms the header and functionality component of the widget. The information that is displayed
2644 // then follows this function followed by a closing div tag
2646 // $title is the title of the section (already translated)
2647 // $label is identifier used in the tag id's and sql columns
2648 // $buttonLabel is the button label text (already translated)
2649 // $buttonLink is the button link information
2650 // $buttonClass is any additional needed class elements for the button tag
2651 // $linkMethod is the button link method ('javascript' vs 'html')
2652 // $bodyClass is to set class(es) of the body
2653 // $auth is a flag to decide whether to show the button
2654 // $fixedWidth is to flag whether width is fixed
2655 // $forceExpandAlways is a flag to force the widget to always be expanded
2657 function expand_collapse_widget($title, $label, $buttonLabel, $buttonLink, $buttonClass, $linkMethod, $bodyClass, $auth, $fixedWidth, $forceExpandAlways=false) {
2659 echo "<div class='section-header'>";
2662 echo "<div class='section-header-dynamic'>";
2666 // show button, since authorized
2667 // first prepare class string
2669 $class_string = "css_button_small ".htmlspecialchars( $buttonClass, ENT_NOQUOTES
);
2672 $class_string = "css_button_small";
2674 // next, create the link
2675 if ($linkMethod == "javascript") {
2676 echo "<td><a class='" . $class_string . "' href='javascript:;' onclick='" . $buttonLink . "'";
2679 echo "<td><a class='" . $class_string . "' href='" . $buttonLink . "'";
2680 if (!isset($_SESSION['patient_portal_onsite'])) {
2681 // prevent an error from occuring when calling the function from the patient portal
2682 echo " onclick='top.restoreSession()'";
2685 if (!$GLOBALS['concurrent_layout']) {
2686 echo " target='Main'";
2689 htmlspecialchars( $buttonLabel, ENT_NOQUOTES
) . "</span></a></td>";
2691 if ($forceExpandAlways){
2692 // Special case to force the widget to always be expanded
2693 echo "<td><span class='text'><b>" . htmlspecialchars( $title, ENT_NOQUOTES
) . "</b></span>";
2694 $indicatorTag ="style='display:none'";
2696 $indicatorTag = isset($indicatorTag) ?
$indicatorTag : "";
2697 echo "<td><a " . $indicatorTag . " href='javascript:;' class='small' onclick='toggleIndicator(this,\"" .
2698 htmlspecialchars( $label, ENT_QUOTES
) . "_ps_expand\")'><span class='text'><b>";
2699 echo htmlspecialchars( $title, ENT_NOQUOTES
) . "</b></span>";
2701 if (isset($_SESSION['patient_portal_onsite'])) {
2702 // collapse all entries in the patient portal
2703 $text = xl('expand');
2705 else if (getUserSetting($label."_ps_expand")) {
2706 $text = xl('collapse');
2709 $text = xl('expand');
2711 echo " (<span class='indicator'>" . htmlspecialchars($text, ENT_QUOTES
) .
2712 "</span>)</a></td>";
2713 echo "</tr></table>";
2715 if ($forceExpandAlways) {
2716 // Special case to force the widget to always be expanded
2719 else if (isset($_SESSION['patient_portal_onsite'])) {
2720 // collapse all entries in the patient portal
2721 $styling = "style='display:none'";
2723 else if (getUserSetting($label."_ps_expand")) {
2727 $styling = "style='display:none'";
2730 $styling .= " class='" . $bodyClass . "'";
2732 //next, create the first div tag to hold the information
2733 // note the code that calls this function will then place the ending div tag after the data
2734 echo "<div id='" . htmlspecialchars( $label, ENT_QUOTES
) . "_ps_expand' " . $styling . ">";
2737 //billing_facility fuction will give the dropdown list which contain billing faciliies.
2738 function billing_facility($name,$select){
2739 $qsql = sqlStatement("SELECT id, name FROM facility WHERE billing_location = 1");
2740 echo " <select id='".htmlspecialchars($name, ENT_QUOTES
)."' name='".htmlspecialchars($name, ENT_QUOTES
)."'>";
2741 while ($facrow = sqlFetchArray($qsql)) {
2742 $selected = ( $facrow['id'] == $select ) ?
'selected="selected"' : '' ;
2743 echo "<option value=".htmlspecialchars($facrow['id'],ENT_QUOTES
)." $selected>".htmlspecialchars($facrow['name'], ENT_QUOTES
)."</option>";
2748 // Generic function to get the translated title value for a particular list option.
2750 function getListItemTitle($list, $option) {
2751 $row = sqlQuery("SELECT title FROM list_options WHERE " .
2752 "list_id = ? AND option_id = ?", array($list, $option));
2753 if (empty($row['title'])) return $option;
2754 return xl_list_label($row['title']);