function generate_display_field($frow, $currvalue) { $data_type = $frow['data_type']; $field_id = $frow['field_id']; $list_id = $frow['list_id']; $s = ''; // generic selection list or the generic selection list with add on the fly // feature, or radio buttons if ($data_type == 1 || $data_type == 26 || $data_type == 27) { $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); } else { if ($data_type == 2) { $s = htmlspecialchars($currvalue, ENT_NOQUOTES); } else { if ($data_type == 3) { $s = nl2br(htmlspecialchars($currvalue, ENT_NOQUOTES)); } else { if ($data_type == 4) { $s = htmlspecialchars(oeFormatShortDate($currvalue), ENT_NOQUOTES); } 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 == 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 .= 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) . ": </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) . " </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) . " </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) . " </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) { $tmp = explode('|', $currvalue); switch (count($tmp)) { 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 (!empty($resnote)) { $s .= "<td class='text' valign='top'>" . htmlspecialchars($resnote, ENT_NOQUOTES) . " </td>"; } if (!empty($res)) { $s .= "<td class='text' valign='top'><b>" . htmlspecialchars(xl('Status'), ENT_NOQUOTES) . "</b>: " . htmlspecialchars($res, ENT_NOQUOTES) . " </td>"; } if ($restype == "quit" . $field_id) { $s .= "<td class='text' valign='top'>" . htmlspecialchars($resdate, ENT_NOQUOTES) . " </td>"; } $s .= "</tr>"; $s .= "</table>"; } else { if ($data_type == 31) { $s .= nl2br($frow['description']); } } } } } } } } } } } } } } } } return $s; }
function generate_plaintext_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['backup_list']; $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 = xl_list_label($lrow['title']); //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 = xl_list_label($lrow['title']); } } else { if ($data_type == 2 || $data_type == 3 || $data_type == 15) { $s = $currvalue; } else { if ($data_type == 4) { $s = oeFormatShortDate($currvalue); // Optional display of age or gestational age. $tmp = optionalAge($frow, $currvalue); if ($tmp) { $s .= ' ' . $tmp; } } else { if ($data_type == 10 || $data_type == 11) { $urow = sqlQuery("SELECT fname, lname, specialty FROM users " . "WHERE id = ?", array($currvalue)); $s = ucwords($urow['fname'] . " " . $urow['lname']); } else { if ($data_type == 12) { $pres = get_pharmacies(); while ($prow = sqlFetchArray($pres)) { $key = $prow['id']; if ($currvalue == $key) { $s .= $prow['name'] . ' ' . $prow['area_code'] . '-' . $prow['prefix'] . '-' . $prow['number'] . ' / ' . $prow['line1'] . ' / ' . $prow['city']; } } } 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 = $uname; } else { if ($data_type == 16) { $insprovs = getInsuranceProviders(); foreach ($insprovs as $key => $ipname) { if ($currvalue == $key) { $s .= $ipname; } } } else { if ($data_type == 17) { foreach ($ISSUE_TYPES as $key => $value) { if ($currvalue == $key) { $s .= $value[1]; } } } else { if ($data_type == 18) { $crow = sqlQuery("SELECT pc_catid, pc_catname " . "FROM openemr_postcalendar_categories WHERE pc_catid = ?", array($currvalue)); $s = $crow['pc_catname']; } 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 .= "; "; } $s .= xl_list_label($lrow['title']); } } } 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)); while ($lrow = sqlFetchArray($lres)) { $option_id = $lrow['option_id']; if (empty($avalue[$option_id])) { continue; } if ($s !== '') { $s .= '; '; } $s .= xl_list_label($lrow['title']) . ': '; $s .= $avalue[$option_id]; } } 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)); 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; } if ($restype != '2') { continue; } // show abnormal results only if ($s !== '') { $s .= '; '; } $s .= xl_list_label($lrow['title']); if (!empty($resnote)) { $s .= ': ' . $resnote; } } } else { if ($data_type == 24) { $query = "SELECT title, comments FROM lists WHERE " . "pid = ? AND type = 'allergy' AND enddate IS NULL " . "ORDER BY begdate"; $lres = sqlStatement($query, array($GLOBALS['pid'])); $count = 0; while ($lrow = sqlFetchArray($lres)) { if ($count++) { $s .= "; "; } $s .= $lrow['title']; if ($lrow['comments']) { $s .= ' (' . $lrow['comments'] . ')'; } } } 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)); 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; } if ($s !== '') { $s .= '; '; } $s .= xl_list_label($lrow['title']); $restype = $restype ? xl('Yes') : xl('No'); $s .= $restype; if ($resnote) { $s .= ' ' . $resnote; } } } else { if ($data_type == 28 || $data_type == 32) { $tmp = explode('|', $currvalue); $resnote = count($tmp) > 0 ? $tmp[0] : ''; $restype = count($tmp) > 1 ? $tmp[1] : ''; $resdate = count($tmp) > 2 ? $tmp[2] : ''; $reslist = count($tmp) > 3 ? $tmp[3] : ''; $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'); } if ($data_type == 28) { if (!empty($resnote)) { $s .= $resnote; } } else { if ($data_type == 32) { if (!empty($reslist)) { $s .= generate_plaintext_field(array('data_type' => '1', 'list_id' => $list_id), $reslist); } if (!empty($resnote)) { $s .= ' ' . $resnote; } } } if (!empty($res)) { if ($s !== '') { $s .= ' '; } $s .= xl('Status') . ' ' . $res; } if ($restype == "quit" . $field_id) { if ($s !== '') { $s .= ' '; } $s .= $resdate; } } 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 . ", " . xl_list_label($lrow['title']); } else { $s = xl_list_label($lrow['title']); } $i++; } } } } } } } } } } } } } } } } } return $s; }