Пример #1
0
    } else {
        $odrstmt = " ORDER BY " . ltrim($odrstmt, ",");
    }
    if ($type == 'Medical History') {
        $sqlstmt = "select * from (" . $sqlstmt . " " . $whr_stmt . " " . $odrstmt . ",history_data_date desc) a group by patient_id";
    } else {
        $sqlstmt = $sqlstmt . " " . $whr_stmt . " " . $odrstmt;
    }
    $result = sqlStatement($sqlstmt, $sqlBindArray);
    $row_id = 1.1;
    //given to each row to identify and toggle
    $img_id = 1.2;
    $k = 1.3;
    if (sqlNumRows($result) > 0) {
        //Added on 6-jun-2k14(regarding displaying smoking code descriptions)
        $smoke_codes_arr = getSmokeCodes();
        ?>
<br>
	<div id = "report_results">
		
	<?php 
        $pidarr = array();
        while ($row = sqlFetchArray($result)) {
            ?>
	<table width=90% align="center" cellpadding="5" cellspacing="0" style="font-family:tahoma;color:black;" border="0">
		<tr bgcolor = "#CCCCCC" style="font-size:15px;">
			<td><b><?php 
            echo htmlspecialchars(xl('Summary of'), ENT_NOQUOTES);
            echo " ";
            ?>
 <?php 
Пример #2
0
include_once "{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php";
?>
<script type="text/javascript" src="../../../library/dynarch_calendar_setup.js"></script>

<script type="text/javascript" src="../../../library/js/jquery.1.3.2.js"></script>
<script type="text/javascript" src="../../../library/js/common.js"></script>
<?php 
include_once "{$GLOBALS['srcdir']}/options.js.php";
?>

<script LANGUAGE="JavaScript">
 //Added on 5-jun-2k14 (regarding 'Smoking Status - display SNOMED code description')
 var code_options_js = Array();
 
 <?php 
$smoke_codes = getSmokeCodes();
foreach ($smoke_codes as $val => $code) {
    echo "code_options_js" . "['" . attr($val) . "']='" . attr($code) . "';\n";
}
?>
     
var mypcc = '<?php 
echo $GLOBALS['phone_country_code'];
?>
';

function divclick(cb, divid) {
 var divstyle = document.getElementById(divid).style;
 if (cb.checked) {
  divstyle.display = 'block';
 } else {
Пример #3
0
function generate_display_field($frow, $currvalue)
{
    global $ISSUE_TYPES;
    $data_type = $frow['data_type'];
    $field_id = isset($frow['field_id']) ? $frow['field_id'] : null;
    $list_id = $frow['list_id'];
    $backup_list = $frow['list_backup_id'];
    $s = '';
    // generic selection list or the generic selection list with add on the fly
    // feature, or radio buttons
    //  Supports backup lists for datatypes 1,26,33
    if ($data_type == 1 || $data_type == 26 || $data_type == 27 || $data_type == 33) {
        $lrow = sqlQuery("SELECT title FROM list_options " . "WHERE list_id = ? AND option_id = ?", array($list_id, $currvalue));
        $s = htmlspecialchars(xl_list_label($lrow['title']), ENT_NOQUOTES);
        //if there is no matching value in the corresponding lists check backup list
        // only supported in data types 1,26,33
        if ($lrow == 0 && !empty($backup_list) && ($data_type == 1 || $data_type == 26 || $data_type == 33)) {
            $lrow = sqlQuery("SELECT title FROM list_options " . "WHERE list_id = ? AND option_id = ?", array($backup_list, $currvalue));
            $s = htmlspecialchars(xl_list_label($lrow['title']), ENT_NOQUOTES);
        }
    } else {
        if ($data_type == 2) {
            $s = nl2br(htmlspecialchars($currvalue, ENT_NOQUOTES));
        } else {
            if ($data_type == 3) {
                $s = nl2br(htmlspecialchars($currvalue, ENT_NOQUOTES));
            } else {
                if ($data_type == 4) {
                    $s = '';
                    $agestr = optionalAge($frow, $currvalue);
                    if ($agestr) {
                        $s .= "<table cellpadding='0' cellspacing='0'><tr><td class='text'>";
                    }
                    if ($currvalue === '') {
                        $s .= '&nbsp;';
                    } else {
                        $s .= text(oeFormatShortDate($currvalue));
                    }
                    // Optional display of age or gestational age.
                    if ($agestr) {
                        $s .= "</td></tr><tr><td class='text'>" . text($agestr) . "</td></tr></table>";
                    }
                } else {
                    if ($data_type == 10 || $data_type == 11) {
                        $urow = sqlQuery("SELECT fname, lname, specialty FROM users " . "WHERE id = ?", array($currvalue));
                        $s = htmlspecialchars(ucwords($urow['fname'] . " " . $urow['lname']), ENT_NOQUOTES);
                    } else {
                        if ($data_type == 12) {
                            $pres = get_pharmacies();
                            while ($prow = sqlFetchArray($pres)) {
                                $key = $prow['id'];
                                if ($currvalue == $key) {
                                    $s .= htmlspecialchars($prow['name'] . ' ' . $prow['area_code'] . '-' . $prow['prefix'] . '-' . $prow['number'] . ' / ' . $prow['line1'] . ' / ' . $prow['city'], ENT_NOQUOTES);
                                }
                            }
                        } else {
                            if ($data_type == 13) {
                                $squads = acl_get_squads();
                                if ($squads) {
                                    foreach ($squads as $key => $value) {
                                        if ($currvalue == $key) {
                                            $s .= htmlspecialchars($value[3], ENT_NOQUOTES);
                                        }
                                    }
                                }
                            } else {
                                if ($data_type == 14) {
                                    $urow = sqlQuery("SELECT fname, lname, specialty FROM users " . "WHERE id = ?", array($currvalue));
                                    $uname = $urow['lname'];
                                    if ($urow['fname']) {
                                        $uname .= ", " . $urow['fname'];
                                    }
                                    $s = htmlspecialchars($uname, ENT_NOQUOTES);
                                } else {
                                    if ($data_type == 15) {
                                        $s = htmlspecialchars($currvalue, ENT_NOQUOTES);
                                    } else {
                                        if ($data_type == 16) {
                                            $insprovs = getInsuranceProviders();
                                            foreach ($insprovs as $key => $ipname) {
                                                if ($currvalue == $key) {
                                                    $s .= htmlspecialchars($ipname, ENT_NOQUOTES);
                                                }
                                            }
                                        } else {
                                            if ($data_type == 17) {
                                                foreach ($ISSUE_TYPES as $key => $value) {
                                                    if ($currvalue == $key) {
                                                        $s .= htmlspecialchars($value[1], ENT_NOQUOTES);
                                                    }
                                                }
                                            } else {
                                                if ($data_type == 18) {
                                                    $crow = sqlQuery("SELECT pc_catid, pc_catname " . "FROM openemr_postcalendar_categories WHERE pc_catid = ?", array($currvalue));
                                                    $s = htmlspecialchars($crow['pc_catname'], ENT_NOQUOTES);
                                                } else {
                                                    if ($data_type == 21) {
                                                        $avalue = explode('|', $currvalue);
                                                        $lres = sqlStatement("SELECT * FROM list_options " . "WHERE list_id = ? ORDER BY seq, title", array($list_id));
                                                        $count = 0;
                                                        while ($lrow = sqlFetchArray($lres)) {
                                                            $option_id = $lrow['option_id'];
                                                            if (in_array($option_id, $avalue)) {
                                                                if ($count++) {
                                                                    $s .= "<br />";
                                                                }
                                                                // Added 5-09 by BM - Translate label if applicable
                                                                $s .= nl2br(htmlspecialchars(xl_list_label($lrow['title'])), ENT_NOQUOTES);
                                                            }
                                                        }
                                                    } else {
                                                        if ($data_type == 22) {
                                                            $tmp = explode('|', $currvalue);
                                                            $avalue = array();
                                                            foreach ($tmp as $value) {
                                                                if (preg_match('/^([^:]+):(.*)$/', $value, $matches)) {
                                                                    $avalue[$matches[1]] = $matches[2];
                                                                }
                                                            }
                                                            $lres = sqlStatement("SELECT * FROM list_options " . "WHERE list_id = ? ORDER BY seq, title", array($list_id));
                                                            $s .= "<table cellpadding='0' cellspacing='0'>";
                                                            while ($lrow = sqlFetchArray($lres)) {
                                                                $option_id = $lrow['option_id'];
                                                                if (empty($avalue[$option_id])) {
                                                                    continue;
                                                                }
                                                                // Added 5-09 by BM - Translate label if applicable
                                                                $s .= "<tr><td class='bold' valign='top'>" . htmlspecialchars(xl_list_label($lrow['title']), ENT_NOQUOTES) . ":&nbsp;</td>";
                                                                $s .= "<td class='text' valign='top'>" . htmlspecialchars($avalue[$option_id], ENT_NOQUOTES) . "</td></tr>";
                                                            }
                                                            $s .= "</table>";
                                                        } else {
                                                            if ($data_type == 23) {
                                                                $tmp = explode('|', $currvalue);
                                                                $avalue = array();
                                                                foreach ($tmp as $value) {
                                                                    if (preg_match('/^([^:]+):(.*)$/', $value, $matches)) {
                                                                        $avalue[$matches[1]] = $matches[2];
                                                                    }
                                                                }
                                                                $lres = sqlStatement("SELECT * FROM list_options " . "WHERE list_id = ? ORDER BY seq, title", array($list_id));
                                                                $s .= "<table cellpadding='0' cellspacing='0'>";
                                                                while ($lrow = sqlFetchArray($lres)) {
                                                                    $option_id = $lrow['option_id'];
                                                                    $restype = substr($avalue[$option_id], 0, 1);
                                                                    $resnote = substr($avalue[$option_id], 2);
                                                                    if (empty($restype) && empty($resnote)) {
                                                                        continue;
                                                                    }
                                                                    // Added 5-09 by BM - Translate label if applicable
                                                                    $s .= "<tr><td class='bold' valign='top'>" . htmlspecialchars(xl_list_label($lrow['title']), ENT_NOQUOTES) . "&nbsp;</td>";
                                                                    $restype = $restype == '1' ? xl('Normal') : ($restype == '2' ? xl('Abnormal') : xl('N/A'));
                                                                    // $s .= "<td class='text' valign='top'>$restype</td></tr>";
                                                                    // $s .= "<td class='text' valign='top'>$resnote</td></tr>";
                                                                    $s .= "<td class='text' valign='top'>" . htmlspecialchars($restype, ENT_NOQUOTES) . "&nbsp;</td>";
                                                                    $s .= "<td class='text' valign='top'>" . htmlspecialchars($resnote, ENT_NOQUOTES) . "</td>";
                                                                    $s .= "</tr>";
                                                                }
                                                                $s .= "</table>";
                                                            } else {
                                                                if ($data_type == 24) {
                                                                    $query = "SELECT title, comments FROM lists WHERE " . "pid = ? AND type = 'allergy' AND enddate IS NULL " . "ORDER BY begdate";
                                                                    // echo "<!-- $query -->\n"; // debugging
                                                                    $lres = sqlStatement($query, array($GLOBALS['pid']));
                                                                    $count = 0;
                                                                    while ($lrow = sqlFetchArray($lres)) {
                                                                        if ($count++) {
                                                                            $s .= "<br />";
                                                                        }
                                                                        $s .= htmlspecialchars($lrow['title'], ENT_NOQUOTES);
                                                                        if ($lrow['comments']) {
                                                                            $s .= ' (' . htmlspecialchars($lrow['comments'], ENT_NOQUOTES) . ')';
                                                                        }
                                                                    }
                                                                } else {
                                                                    if ($data_type == 25) {
                                                                        $tmp = explode('|', $currvalue);
                                                                        $avalue = array();
                                                                        foreach ($tmp as $value) {
                                                                            if (preg_match('/^([^:]+):(.*)$/', $value, $matches)) {
                                                                                $avalue[$matches[1]] = $matches[2];
                                                                            }
                                                                        }
                                                                        $lres = sqlStatement("SELECT * FROM list_options " . "WHERE list_id = ? ORDER BY seq, title", array($list_id));
                                                                        $s .= "<table cellpadding='0' cellspacing='0'>";
                                                                        while ($lrow = sqlFetchArray($lres)) {
                                                                            $option_id = $lrow['option_id'];
                                                                            $restype = substr($avalue[$option_id], 0, 1);
                                                                            $resnote = substr($avalue[$option_id], 2);
                                                                            if (empty($restype) && empty($resnote)) {
                                                                                continue;
                                                                            }
                                                                            // Added 5-09 by BM - Translate label if applicable
                                                                            $s .= "<tr><td class='bold' valign='top'>" . htmlspecialchars(xl_list_label($lrow['title']), ENT_NOQUOTES) . "&nbsp;</td>";
                                                                            $restype = $restype ? xl('Yes') : xl('No');
                                                                            $s .= "<td class='text' valign='top'>" . htmlspecialchars($restype, ENT_NOQUOTES) . "</td></tr>";
                                                                            $s .= "<td class='text' valign='top'>" . htmlspecialchars($resnote, ENT_NOQUOTES) . "</td></tr>";
                                                                            $s .= "</tr>";
                                                                        }
                                                                        $s .= "</table>";
                                                                    } else {
                                                                        if ($data_type == 28 || $data_type == 32) {
                                                                            $tmp = explode('|', $currvalue);
                                                                            switch (count($tmp)) {
                                                                                case "4":
                                                                                    $resnote = $tmp[0];
                                                                                    $restype = $tmp[1];
                                                                                    $resdate = $tmp[2];
                                                                                    $reslist = $tmp[3];
                                                                                    break;
                                                                                case "3":
                                                                                    $resnote = $tmp[0];
                                                                                    $restype = $tmp[1];
                                                                                    $resdate = $tmp[2];
                                                                                    break;
                                                                                case "2":
                                                                                    $resnote = $tmp[0];
                                                                                    $restype = $tmp[1];
                                                                                    $resdate = "";
                                                                                    break;
                                                                                case "1":
                                                                                    $resnote = $tmp[0];
                                                                                    $resdate = $restype = "";
                                                                                    break;
                                                                                default:
                                                                                    $restype = $resdate = $resnote = "";
                                                                                    break;
                                                                            }
                                                                            $s .= "<table cellpadding='0' cellspacing='0'>";
                                                                            $s .= "<tr>";
                                                                            $res = "";
                                                                            if ($restype == "current" . $field_id) {
                                                                                $res = xl('Current');
                                                                            }
                                                                            if ($restype == "quit" . $field_id) {
                                                                                $res = xl('Quit');
                                                                            }
                                                                            if ($restype == "never" . $field_id) {
                                                                                $res = xl('Never');
                                                                            }
                                                                            if ($restype == "not_applicable" . $field_id) {
                                                                                $res = xl('N/A');
                                                                            }
                                                                            // $s .= "<td class='text' valign='top'>$restype</td></tr>";
                                                                            // $s .= "<td class='text' valign='top'>$resnote</td></tr>";
                                                                            if ($data_type == 28) {
                                                                                if (!empty($resnote)) {
                                                                                    $s .= "<td class='text' valign='top'>" . htmlspecialchars($resnote, ENT_NOQUOTES) . "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>";
                                                                                }
                                                                            } else {
                                                                                if ($data_type == 32) {
                                                                                    //changes on 5-jun-2k14 (regarding 'Smoking Status - display SNOMED code description')
                                                                                    $smoke_codes = getSmokeCodes();
                                                                                    if (!empty($reslist)) {
                                                                                        if ($smoke_codes[$reslist] != "") {
                                                                                            $code_desc = "( " . $smoke_codes[$reslist] . " )";
                                                                                        }
                                                                                        $s .= "<td class='text' valign='top'>" . generate_display_field(array('data_type' => '1', 'list_id' => $list_id), $reslist) . "&nbsp;" . text($code_desc) . "&nbsp;&nbsp;&nbsp;&nbsp;</td>";
                                                                                    }
                                                                                    if (!empty($resnote)) {
                                                                                        $s .= "<td class='text' valign='top'>" . htmlspecialchars($resnote, ENT_NOQUOTES) . "&nbsp;&nbsp;</td>";
                                                                                    }
                                                                                }
                                                                            }
                                                                            if (!empty($res)) {
                                                                                $s .= "<td class='text' valign='top'><b>" . htmlspecialchars(xl('Status'), ENT_NOQUOTES) . "</b>:&nbsp;" . htmlspecialchars($res, ENT_NOQUOTES) . "&nbsp;</td>";
                                                                            }
                                                                            if ($restype == "quit" . $field_id) {
                                                                                $s .= "<td class='text' valign='top'>" . htmlspecialchars($resdate, ENT_NOQUOTES) . "&nbsp;</td>";
                                                                            }
                                                                            $s .= "</tr>";
                                                                            $s .= "</table>";
                                                                        } else {
                                                                            if ($data_type == 31) {
                                                                                $s .= nl2br($frow['description']);
                                                                            } else {
                                                                                if ($data_type == 34) {
                                                                                    $arr = explode("|*|*|*|", $currvalue);
                                                                                    for ($i = 0; $i < sizeof($arr); $i++) {
                                                                                        $s .= $arr[$i];
                                                                                    }
                                                                                } else {
                                                                                    if ($data_type == 35) {
                                                                                        $urow = sqlQuery("SELECT id, name FROM facility " . "WHERE id = ?", array($currvalue));
                                                                                        $s = htmlspecialchars($urow['name'], ENT_NOQUOTES);
                                                                                    } else {
                                                                                        if ($data_type == 36) {
                                                                                            $values_array = explode("|", $currvalue);
                                                                                            $i = 0;
                                                                                            foreach ($values_array as $value) {
                                                                                                $lrow = sqlQuery("SELECT title FROM list_options " . "WHERE list_id = ? AND option_id = ?", array($list_id, $value));
                                                                                                if ($lrow == 0 && !empty($backup_list)) {
                                                                                                    //use back up list
                                                                                                    $lrow = sqlQuery("SELECT title FROM list_options " . "WHERE list_id = ? AND option_id = ?", array($backup_list, $value));
                                                                                                }
                                                                                                if ($i > 0) {
                                                                                                    $s = $s . ", " . htmlspecialchars(xl_list_label($lrow['title']), ENT_NOQUOTES);
                                                                                                } else {
                                                                                                    $s = htmlspecialchars(xl_list_label($lrow['title']), ENT_NOQUOTES);
                                                                                                }
                                                                                                $i++;
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    return $s;
}
Пример #4
0
function generate_display_field($frow, $currvalue) {
  global $ISSUE_TYPES;

  $data_type  = $frow['data_type'];
  $field_id   = isset($frow['field_id'])  ? $frow['field_id'] : null;
  $list_id    = $frow['list_id'];
  $backup_list = isset($frow['list_backup_id']) ? $frow['list_backup_id'] : null;

  $s = '';

  // generic selection list or the generic selection list with add on the fly
  // feature, or radio buttons
  //  Supports backup lists for datatypes 1,26,33
  if ($data_type == 1 || $data_type == 26 || $data_type == 27 || $data_type == 33) {
    $lrow = sqlQuery("SELECT title FROM list_options " .
      "WHERE list_id = ? AND option_id = ? AND activity = 1", array($list_id,$currvalue) );
      $s = htmlspecialchars(xl_list_label($lrow['title']),ENT_NOQUOTES);
    //if there is no matching value in the corresponding lists check backup list
    // only supported in data types 1,26,33
    if ($lrow == 0 && !empty($backup_list) && ($data_type == 1 || $data_type == 26 || $data_type == 33)) {
      $lrow = sqlQuery("SELECT title FROM list_options " .
        "WHERE list_id = ? AND option_id = ? AND activity = 1", array($backup_list,$currvalue) );
      $s = htmlspecialchars(xl_list_label($lrow['title']),ENT_NOQUOTES);
    }
  }

  // simple text field
  else if ($data_type == 2) {
     $s = nl2br(htmlspecialchars($currvalue,ENT_NOQUOTES));
  }

  // long or multi-line text field
  else if ($data_type == 3) {
    $s = nl2br(htmlspecialchars($currvalue,ENT_NOQUOTES));
  }

  // date
  else if ($data_type == 4) {
    $asof = ''; //not used here, but set to prevent a php warning when call optionalAge
    $s = '';
    $agestr = optionalAge($frow, $currvalue, $asof);
    if ($agestr) {
      $s .= "<table cellpadding='0' cellspacing='0'><tr><td class='text'>";
    }
    if ($currvalue === '') {
      $s .= '&nbsp;';
    }
    else {
      $s .= text(oeFormatShortDate($currvalue));
    }
    // Optional display of age or gestational age.
    if ($agestr) {
      $s .= "</td></tr><tr><td class='text'>" . text($agestr) . "</td></tr></table>";
    }
  }

  // provider
  else if ($data_type == 10 || $data_type == 11) {
    $urow = sqlQuery("SELECT fname, lname, specialty FROM users " .
      "WHERE id = ?", array($currvalue) );
    $s = htmlspecialchars(ucwords($urow['fname'] . " " . $urow['lname']),ENT_NOQUOTES);
  }

  // pharmacy list
  else if ($data_type == 12) {
    $pres = get_pharmacies();
    while ($prow = sqlFetchArray($pres)) {
      $key = $prow['id'];
      if ($currvalue == $key) {
        $s .= htmlspecialchars($prow['name'] . ' ' . $prow['area_code'] . '-' .
          $prow['prefix'] . '-' . $prow['number'] . ' / ' .
          $prow['line1'] . ' / ' . $prow['city'],ENT_NOQUOTES);
      }
    }
  }

  // squads
  else if ($data_type == 13) {
    $squads = acl_get_squads();
    if ($squads) {
      foreach ($squads as $key => $value) {
        if ($currvalue == $key) {
          $s .= htmlspecialchars($value[3],ENT_NOQUOTES);
        }
      }
    }
  }

  // address book
  else if ($data_type == 14) {
    $urow = sqlQuery("SELECT fname, lname, specialty, organization FROM users " .
      "WHERE id = ?", array($currvalue));
    //ViSolve: To display the Organization Name if it exist. Else it will display the user name.
    if($urow['organization'] !=""){
    	$uname = $urow['organization'];
    }else{
    	$uname = $urow['lname'];
    	if ($urow['fname']) $uname .= ", " . $urow['fname'];
    }
    $s = htmlspecialchars($uname,ENT_NOQUOTES);
  }

  // billing code
  else if ($data_type == 15) {
    $s = htmlspecialchars($currvalue,ENT_NOQUOTES);
  }

  // insurance company list
  else if ($data_type == 16) {
    $insprovs = getInsuranceProviders();
    foreach ($insprovs as $key => $ipname) {
      if ($currvalue == $key) {
        $s .= htmlspecialchars($ipname, ENT_NOQUOTES);
      }
    }
  }

  // issue types
  else if ($data_type == 17) {
    foreach ($ISSUE_TYPES as $key => $value) {
      if ($currvalue == $key) {
        $s .= htmlspecialchars($value[1], ENT_NOQUOTES);
      }
    }
  }

  // visit category
  else if ($data_type == 18) {
    $crow = sqlQuery("SELECT pc_catid, pc_catname " .
      "FROM openemr_postcalendar_categories WHERE pc_catid = ?",
      array($currvalue));
    $s = htmlspecialchars($crow['pc_catname'],ENT_NOQUOTES);
  }

  // a set of labeled checkboxes
  else if ($data_type == 21) {
    $avalue = explode('|', $currvalue);
    $lres = sqlStatement("SELECT * FROM list_options " .
      "WHERE list_id = ? AND activity = 1 ORDER BY seq, title", array($list_id) );
    $count = 0;
    while ($lrow = sqlFetchArray($lres)) {
      $option_id = $lrow['option_id'];
      if (in_array($option_id, $avalue)) {
        if ($count++) $s .= "<br />";

	// Added 5-09 by BM - Translate label if applicable
        $s .= nl2br(htmlspecialchars(xl_list_label($lrow['title'])),ENT_NOQUOTES);

      }
    }
  }

  // a set of labeled text input fields
  else if ($data_type == 22) {
    $tmp = explode('|', $currvalue);
    $avalue = array();
    foreach ($tmp as $value) {
      if (preg_match('/^([^:]+):(.*)$/', $value, $matches)) {
        $avalue[$matches[1]] = $matches[2];
      }
    }
    $lres = sqlStatement("SELECT * FROM list_options " .
      "WHERE list_id = ? AND activity = 1 ORDER BY seq, title", array($list_id) );
    $s .= "<table cellpadding='0' cellspacing='0'>";
    while ($lrow = sqlFetchArray($lres)) {
      $option_id = $lrow['option_id'];
      if (empty($avalue[$option_id])) continue;

      // Added 5-09 by BM - Translate label if applicable
      $s .= "<tr><td class='bold' valign='top'>" . htmlspecialchars(xl_list_label($lrow['title']),ENT_NOQUOTES) . ":&nbsp;</td>";

      $s .= "<td class='text' valign='top'>" . htmlspecialchars($avalue[$option_id],ENT_NOQUOTES) . "</td></tr>";
    }
    $s .= "</table>";
  }

  // a set of exam results; 3 radio buttons and a text field:
  else if ($data_type == 23) {
    $tmp = explode('|', $currvalue);
    $avalue = array();
    foreach ($tmp as $value) {
      if (preg_match('/^([^:]+):(.*)$/', $value, $matches)) {
        $avalue[$matches[1]] = $matches[2];
      }
    }
    $lres = sqlStatement("SELECT * FROM list_options " .
      "WHERE list_id = ? AND activity = 1 ORDER BY seq, title", array($list_id) );
    $s .= "<table cellpadding='0' cellspacing='0'>";
    while ($lrow = sqlFetchArray($lres)) {
      $option_id = $lrow['option_id'];
      $restype = substr($avalue[$option_id], 0, 1);
      $resnote = substr($avalue[$option_id], 2);
      if (empty($restype) && empty($resnote)) continue;

      // Added 5-09 by BM - Translate label if applicable
      $s .= "<tr><td class='bold' valign='top'>" . htmlspecialchars(xl_list_label($lrow['title']),ENT_NOQUOTES) . "&nbsp;</td>";

      $restype = ($restype == '1') ? xl('Normal') : (($restype == '2') ? xl('Abnormal') : xl('N/A'));
      // $s .= "<td class='text' valign='top'>$restype</td></tr>";
      // $s .= "<td class='text' valign='top'>$resnote</td></tr>";
      $s .= "<td class='text' valign='top'>" . htmlspecialchars($restype,ENT_NOQUOTES) . "&nbsp;</td>";
      $s .= "<td class='text' valign='top'>" . htmlspecialchars($resnote,ENT_NOQUOTES) . "</td>";
      $s .= "</tr>";
    }
    $s .= "</table>";
  }

  // the list of active allergies for the current patient
  else if ($data_type == 24) {
    $query = "SELECT title, comments FROM lists WHERE " .
      "pid = ? AND type = 'allergy' AND enddate IS NULL " .
      "ORDER BY begdate";
    // echo "<!-- $query -->\n"; // debugging
    $lres = sqlStatement($query, array($GLOBALS['pid']) );
    $count = 0;
    while ($lrow = sqlFetchArray($lres)) {
      if ($count++) $s .= "<br />";
      $s .= htmlspecialchars($lrow['title'],ENT_NOQUOTES);
      if ($lrow['comments']) $s .= ' (' . htmlspecialchars($lrow['comments'],ENT_NOQUOTES) . ')';
    }
  }

  // a set of labeled checkboxes, each with a text field:
  else if ($data_type == 25) {
    $tmp = explode('|', $currvalue);
    $avalue = array();
    foreach ($tmp as $value) {
      if (preg_match('/^([^:]+):(.*)$/', $value, $matches)) {
        $avalue[$matches[1]] = $matches[2];
      }
    }
    $lres = sqlStatement("SELECT * FROM list_options " .
      "WHERE list_id = ? AND activity = 1 ORDER BY seq, title", array($list_id) );
    $s .= "<table cellpadding='0' cellspacing='0'>";
    while ($lrow = sqlFetchArray($lres)) {
      $option_id = $lrow['option_id'];
      $restype = substr($avalue[$option_id], 0, 1);
      $resnote = substr($avalue[$option_id], 2);
      if (empty($restype) && empty($resnote)) continue;

      // Added 5-09 by BM - Translate label if applicable
      $s .= "<tr><td class='bold' valign='top'>" . htmlspecialchars(xl_list_label($lrow['title']),ENT_NOQUOTES) . "&nbsp;</td>";

      $restype = $restype ? xl('Yes') : xl('No');
      $s .= "<td class='text' valign='top'>" . htmlspecialchars($restype,ENT_NOQUOTES) . "</td></tr>";
      $s .= "<td class='text' valign='top'>" . htmlspecialchars($resnote,ENT_NOQUOTES) . "</td></tr>";
      $s .= "</tr>";
    }
    $s .= "</table>";
  }

  // special case for history of lifestyle status; 3 radio buttons and a date text field:
  // VicarePlus :: A selection list for smoking status.
  else if ($data_type == 28 || $data_type == 32) {
    $tmp = explode('|', $currvalue);
    switch(count($tmp)) {
      case "4": {
        $resnote = $tmp[0];
        $restype = $tmp[1];
        $resdate = $tmp[2];
        $reslist = $tmp[3];
      } break;
      case "3": {
        $resnote = $tmp[0];
        $restype = $tmp[1];
        $resdate = $tmp[2];
      } break;
      case "2": {
        $resnote = $tmp[0];
        $restype = $tmp[1];
        $resdate = "";
      } break;
      case "1": {
        $resnote = $tmp[0];
        $resdate = $restype = "";
      } break;
      default: {
        $restype = $resdate = $resnote = "";
      } break;
    }
    $s .= "<table cellpadding='0' cellspacing='0'>";

    $s .= "<tr>";
	$res = "";
    if ($restype == "current".$field_id) $res = xl('Current');
	if ($restype == "quit".$field_id) $res = xl('Quit');
	if ($restype == "never".$field_id) $res = xl('Never');
	if ($restype == "not_applicable".$field_id) $res = xl('N/A');
    // $s .= "<td class='text' valign='top'>$restype</td></tr>";
    // $s .= "<td class='text' valign='top'>$resnote</td></tr>";
     if ($data_type == 28)
    {
    if (!empty($resnote)) $s .= "<td class='text' valign='top'>" . htmlspecialchars($resnote,ENT_NOQUOTES) . "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>";
    }
     //VicarePlus :: Tobacco field has a listbox, text box, date field and 3 radio buttons.
     else if ($data_type == 32)
    {//changes on 5-jun-2k14 (regarding 'Smoking Status - display SNOMED code description')
       $smoke_codes = getSmokeCodes();
       if (!empty($reslist)) {
           if($smoke_codes[$reslist]!="")
               $code_desc = "( ".$smoke_codes[$reslist]." )";

           $s .= "<td class='text' valign='top'>" . generate_display_field(array('data_type'=>'1','list_id'=>$list_id),$reslist) . "&nbsp;".text($code_desc)."&nbsp;&nbsp;&nbsp;&nbsp;</td>";}

       if (!empty($resnote)) $s .= "<td class='text' valign='top'>" . htmlspecialchars($resnote,ENT_NOQUOTES) . "&nbsp;&nbsp;</td>";
    }

	if (!empty($res)) $s .= "<td class='text' valign='top'><b>" . htmlspecialchars(xl('Status'),ENT_NOQUOTES) . "</b>:&nbsp;" . htmlspecialchars($res,ENT_NOQUOTES) . "&nbsp;</td>";
    if ($restype == "quit".$field_id) $s .= "<td class='text' valign='top'>" . htmlspecialchars($resdate,ENT_NOQUOTES) . "&nbsp;</td>";
    $s .= "</tr>";
    $s .= "</table>";
  }

  // static text.  read-only, of course.
  else if ($data_type == 31) {
    $s .= nl2br($frow['description']);
  }

  else if($data_type == 34){
    $arr = explode("|*|*|*|",$currvalue);
    for($i=0;$i<sizeof($arr);$i++){
      $s.=$arr[$i];
    }
  }

  // facility
  else if ($data_type == 35) {
    $urow = sqlQuery("SELECT id, name FROM facility ".
      "WHERE id = ?", array($currvalue) );
    $s = htmlspecialchars($urow['name'],ENT_NOQUOTES);
  }

  // Multi select
  //  Supports backup lists
  else if ($data_type == 36) {
    $values_array = explode("|", $currvalue);
    $i = 0;
    foreach($values_array as $value) {
      $lrow = sqlQuery("SELECT title FROM list_options " .
        "WHERE list_id = ? AND option_id = ? AND activity = 1", array($list_id,$value) );
      if ($lrow == 0 && !empty($backup_list)) {
        //use back up list
        $lrow = sqlQuery("SELECT title FROM list_options " .
          "WHERE list_id = ? AND option_id = ? AND activity = 1", array($backup_list,$value) );
      }
      if ($i > 0) {
        $s = $s . ", " . htmlspecialchars(xl_list_label($lrow['title']),ENT_NOQUOTES);
	    } else {
        $s = htmlspecialchars(xl_list_label($lrow['title']),ENT_NOQUOTES);
      }
      $i++;
    }
  }

  // Image from canvas drawing
  else if ($data_type == 40) {
    $s .= "<img src='" . attr($currvalue) . "'>";
  }

  return $s;
}