function showDocument(&$drow) { global $ISSUE_TYPES, $auth_med; $docdate = $drow['docdate']; echo "<tr class='text docrow' id='" . htmlspecialchars($drow['id'], ENT_QUOTES) . "' title='" . htmlspecialchars(xl('View document'), ENT_QUOTES) . "'>\n"; // show date echo "<td>" . htmlspecialchars(oeFormatShortDate($docdate), ENT_NOQUOTES) . "</td>\n"; // show associated issue, if any echo "<td>"; if ($auth_med) { $irow = sqlQuery("SELECT type, title, begdate " . "FROM lists WHERE " . "id = ? " . "LIMIT 1", array($drow['list_id'])); if ($irow) { $tcode = $irow['type']; if ($ISSUE_TYPES[$tcode]) { $tcode = $ISSUE_TYPES[$tcode][2]; } echo htmlspecialchars("{$tcode}: " . $irow['title'], ENT_NOQUOTES); } } else { echo "(" . htmlspecialchars(xl('No access'), ENT_NOQUOTES) . ")"; } echo "</td>\n"; // show document name and category echo "<td colspan='3'>" . htmlspecialchars(xl('Document') . ": " . basename($drow['url']) . ' (' . xl_document_category($drow['name']) . ')', ENT_NOQUOTES) . "</td>\n"; // skip billing and insurance columns if (!$GLOBALS['athletic_team']) { echo "<td colspan=5> </td>\n"; } echo "</tr>\n"; }
function procedure_order_report($pid, $encounter, $cols, $id) { $cols = 1; // force always 1 column $count = 0; $data = sqlQuery("SELECT * " . "FROM procedure_order WHERE " . "procedure_order_id = '{$id}' AND activity = '1'"); if ($data) { print "<table cellpadding='0' cellspacing='0'>\n<tr>\n"; foreach ($data as $key => $value) { if ($key == "procedure_order_id" || $key == "pid" || $key == "user" || $key == "groupname" || $key == "authorized" || $key == "activity" || $key == "date" || $value == "" || $value == "0" || $value == "0.00") { continue; } $key = ucwords(str_replace("_", " ", $key)); if ($key == "Order Priority") { print "<td valign='top'><span class='bold'>" . xl($key) . ": </span><span class='text'>" . generate_display_field(array('data_type' => '1', 'list_id' => 'ord_priority'), $value) . " </span></td>\n"; } else { if ($key == "Order Status") { print "<td valign='top'><span class='bold'>" . xl($key) . ": </span><span class='text'>" . generate_display_field(array('data_type' => '1', 'list_id' => 'ord_status'), $value) . " </span></td>\n"; } else { print "<td valign='top'><span class='bold'>" . xl($key) . ": </span><span class='text'>{$value} </span></td>\n"; } } $count++; if ($count == $cols) { $count = 0; print "</tr>\n<tr>\n"; } } print "</tr>\n</table>\n"; } }
function load_menu($menu_set) { $menuTables = " SHOW TABLES LIKE ?"; $res = sqlQuery($menuTables, array("menu_trees")); if ($res === false) { return array(); } $menuQuery = " SELECT * FROM menu_trees, menu_entries WHERE menu_trees.entry_id=menu_entries.id AND menu_set=? ORDER BY parent, seq"; $res = sqlStatement($menuQuery, array($menu_set)); $retval = array(); $entries = array(); $parent_not_found = array(); while ($row = sqlFetchArray($res)) { $entries[$row['entry_id']] = menu_entry_to_object($row); if (empty($row['parent'])) { array_push($retval, $entries[$row['entry_id']]); } else { if (isset($entries[$row['parent']])) { $parent = $entries[$row['parent']]; array_push($parent->children, $entries[$row['entry_id']]); } else { array_push($parent_not_found, $entries[$row['entry_id']]); } } } foreach ($parent_not_found as $row) { if (isset($entries[$row->parent])) { $parent = $entries[$row->parent]; array_push($parent->children, $row); } else { array_push($parent_not_found2, $row); } } return json_decode(json_encode($retval)); }
public function test(CqmPatient $patient, $beginDate, $endDate) { $age = $patient->calculateAgeOnDate($beginDate); if ($age >= 2 && $age <= 18) { //Children 2-18 years of age who had an outpatient or emergency department (ED) visit with a diagnosis of pharyngitis during the measurement period and an antibiotic ordered on or three days after the visit $pharyngitisArr = array('ICD9:034', 'ICD9:462', 'ICD9:463', 'ICD10:J02.0', 'ICD10:J02.8', 'ICD10:J02.9', 'ICD10:J03.80', 'ICD10:J03.81', 'ICD10:J03.90', 'ICD10:J03.91'); $query = "SELECT l.title as drug FROM form_encounter fe " . "INNER JOIN openemr_postcalendar_categories opc ON fe.pc_catid = opc.pc_catid " . "INNER JOIN lists l ON l.type = 'medication' AND fe.pid = l.pid " . "WHERE opc.pc_catname = 'Office Visit' "; $pharyngitisStr = "("; $cnt = 0; foreach ($pharyngitisArr as $pharyngitisCode) { if ($cnt == 0) { $pharyngitisStr .= " l.diagnosis LIKE '%" . $pharyngitisCode . "%' "; } else { $pharyngitisStr .= " OR l.diagnosis LIKE '%" . $pharyngitisCode . "%' "; } $cnt++; } $pharyngitisStr .= ")"; $query .= " AND " . $pharyngitisStr; $query .= " AND fe.pid = ? AND (fe.date BETWEEN ? AND ?)"; $check = sqlQuery($query, array($patient->id, $beginDate, $endDate)); if ($check['drug'] != "") { return true; } else { return false; } } return false; }
function scanned_notes_report($pid, $useless_encounter, $cols, $id) { global $webserver_root, $web_root, $encounter; // In the case of a patient report, the passed encounter is vital. $thisenc = $useless_encounter ? $useless_encounter : $encounter; $count = 0; $data = sqlQuery("SELECT * " . "FROM form_scanned_notes WHERE " . "id = '{$id}' AND activity = '1'"); if ($data) { echo "<table cellpadding='0' cellspacing='0'>\n"; if ($data['notes']) { echo " <tr>\n"; echo " <td valign='top'><span class='bold'>Comments: </span><span class='text'>"; echo nl2br($data['notes']) . "</span></td>\n"; echo " </tr>\n"; } for ($i = -1; true; ++$i) { $suffix = $i < 0 ? "" : "-{$i}"; $imagepath = $GLOBALS['OE_SITE_DIR'] . "/documents/{$pid}/encounters/{$thisenc}_{$id}{$suffix}.jpg"; $imageurl = "{$web_root}/sites/" . $_SESSION['site_id'] . "/documents/{$pid}/encounters/{$thisenc}_{$id}{$suffix}.jpg"; if (is_file($imagepath)) { echo " <tr>\n"; echo " <td valign='top'>\n"; echo " <img src='{$imageurl}' />\n"; echo " </td>\n"; echo " </tr>\n"; } else { if ($i >= 0) { break; } } } echo "</table>\n"; } }
/** * * @param RuleCriteria $criteria */ function modify($criteria, $ruleId) { // get interval $result = sqlQuery(self::SQL_RULE_INTERVAL, array($ruleId)); $criteria->interval = $result['interval'] ? $result['interval'] : 1; $criteria->intervalType = $result['value'] ? TimeUnit::from($result['value']) : TimeUnit::from(TimeUnit::Month); }
function scanned_notes_report($pid, $useless_encounter, $cols, $id) { global $webserver_root, $web_root, $encounter; // In the case of a patient report, the passed encounter is vital. $thisenc = $useless_encounter ? $useless_encounter : $encounter; $count = 0; $data = sqlQuery("SELECT * " . "FROM form_scanned_notes WHERE " . "id = '{$id}' AND activity = '1'"); if ($data) { if ($data['notes']) { echo " <span class='bold'>Comments: </span><span class='text'>"; echo nl2br($data['notes']) . "</span><br />\n"; } for ($i = -1; true; ++$i) { $suffix = $i < 0 ? "" : "-{$i}"; $imagepath = $GLOBALS['OE_SITE_DIR'] . "/documents/{$pid}/encounters/{$thisenc}_{$id}{$suffix}.jpg"; $imageurl = "{$web_root}/sites/" . $_SESSION['site_id'] . "/documents/{$pid}/encounters/{$thisenc}_{$id}{$suffix}.jpg"; if (is_file($imagepath)) { echo " <img src='{$imageurl}'"; // Flag images with excessive width for possible stylesheet action. $asize = getimagesize($imagepath); if ($asize[0] > 750) { echo " class='bigimage'"; } echo " />\n"; echo " <br />\n"; } else { if ($i >= 0) { break; } } } } }
public function test(CqmPatient $patient, $beginDate, $endDate) { //Children who are taking antibiotics in the 30 days prior to the diagnosis of pharyngitis $pharyngitisArr = array('ICD9:034', 'ICD9:462', 'ICD9:463', 'ICD10:J02.0', 'ICD10:J02.8', 'ICD10:J02.9', 'ICD10:J03.80', 'ICD10:J03.81', 'ICD10:J03.90', 'ICD10:J03.91'); $query = "SELECT count(*) as cnt FROM form_encounter fe " . "INNER JOIN openemr_postcalendar_categories opc ON fe.pc_catid = opc.pc_catid " . "INNER JOIN lists l ON l.type = 'medication' AND fe.pid = l.pid " . "WHERE opc.pc_catname = 'Office Visit' "; $pharyngitisStr = "("; $cnt = 0; foreach ($pharyngitisArr as $pharyngitisCode) { if ($cnt == 0) { $pharyngitisStr .= " l.diagnosis LIKE '%" . $pharyngitisCode . "%' "; } else { $pharyngitisStr .= " OR l.diagnosis LIKE '%" . $pharyngitisCode . "%' "; } $cnt++; } $pharyngitisStr .= ")"; $query .= " AND " . $pharyngitisStr; $query .= " AND fe.pid = ? AND (fe.date BETWEEN ? AND ?)"; $check = sqlQuery($query, array($patient->id, $beginDate, $endDate)); if ($check['cnt'] > 1) { //more than one medication it will exclude return true; } else { return false; } }
function misc_billing_options_report($pid, $encounter, $cols, $id) { $count = 0; $data = formFetch("form_misc_billing_options", $id); if ($data) { print "<table><tr>"; foreach ($data as $key => $value) { if ($key == "id" || $key == "pid" || $key == "user" || $key == "groupname" || $key == "authorized" || $key == "activity" || $key == "date" || $value == "" || $value == "0" || $value == "0000-00-00 00:00:00" || $value == "0000-00-00") { continue; } if ($value == "1") { $value = "yes"; } if ($key === 'box_14_date_qual' || $key === 'box_15_date_qual') { $value = text(qual_id_to_description($key, $value)); } if ($key === 'provider_id') { $trow = sqlQuery("SELECT id, lname, fname FROM users WHERE " . "id = ? ", array($value)); $value = $trow['fname'] . ' ' . $trow['lname']; } $key = ucwords(str_replace("_", " ", $key)); print "<td><span class=bold>{$key}: </span><span class=text>" . text($value) . "</span></td>"; $count++; if ($count == $cols) { $count = 0; print "</tr><tr>\n"; } } } print "</tr></table>"; }
public function test(AmcPatient $patient, $beginDate, $endDate) { $procedure_order_id = $patient->object['procedure_order_id']; $sql = "SELECT count(r.result) as cnt FROM procedure_result r " . "INNER JOIN procedure_report pr ON pr.procedure_report_id = r.procedure_report_id " . "INNER JOIN procedure_order po ON po.procedure_order_id = pr.procedure_order_id " . "WHERE r.result != '' " . "AND po.procedure_order_id = ?"; $check = sqlQuery($sql, array($procedure_order_id)); return $check['cnt']; }
function section_jointeam_doJoin($id, $invite) { // Try to add player to team $obj = mysql_fetch_object(mysql_query("select l_team.id, l_team.name, l_team.leader, count(callsign) nump\n from l_team left join l_player on l_team.id = l_player.team\n where l_team.id = " . $id . "\n group by l_team.id, l_team.name, l_team.leader")); if ($obj->nump == $TEAMSIZE) { // Team full echo "<center>Sorry, this team is full. Probably someone was joining it at the same time...</center>"; } else { // Okay, let's do the update mysql_query("update l_player set team=" . $id . " where id=" . $_SESSION['playerid']); // Close team if it's full if ($obj->nump == $TEAMSIZE - 1) { mysql_query("update l_team set status='closed' where id=" . $id); } // Close team if it has 3 players and is adminclosed if ($obj->nump == 2) { mysql_query("update l_team set status='closed' where adminclosed='yes' and id=" . $id); } echo '<center>You are now a member of the ' . teamLink($obj->name, $obj->id, false) . ' team.<BR> A message has been sent to the team leader.</center>'; session_refresh(); // Send a message to the team leader $player = playerLink($_SESSION['playerid'], $_SESSION['callsign']); if ($invite) { $msg = "{$player} has accepted your invitation, and has joined your team!<BR>"; sqlQuery("DELETE FROM bzl_invites WHERE teamid={$obj->id} AND \n playerid={$_SESSION['playerid']}"); } else { $msg = "A new player just joined your team: {$player}"; } sendBzMail(0, $obj->leader, $_SESSION['callsign'] . ' joined your team!', $msg); } }
function ippf_srh_report($pid, $encounter, $cols, $id) { require_once $GLOBALS["srcdir"] . "/options.inc.php"; echo "<table>\n"; display_layout_rows('SRH', sqlQuery("SELECT * FROM form_ippf_srh WHERE id = '{$id}'")); echo "</table>\n"; }
function timetable($hour, $row) { global $rs; // if $rs is null then query database (this should be executed only once - first time) if ($rs === null) { // first column of the query is used as key in returned array $rs = sqlQuery("select concat(t.tbl_row,'_',t.tbl_col) as pos, t.tbl_id, t.sub_id, s.sub_name\n\t\t\t\t\t\tfrom redips_timetable t, redips_subject s\n\t\t\t\t\t\twhere t.sub_id = s.sub_id", 0); } print '<tr>'; print '<td class="mark dark">' . $hour . '</td>'; // column loop starts from 1 because column 0 is for hours for ($col = 1; $col <= 5; $col++) { // create table cell print '<td>'; // prepare position key in the same way as the array key looks $pos = $row . '_' . $col; // if content for the current table cell exists if (array_key_exists($pos, $rs)) { // prepare elements for defined position (it can be more than one element per table cell) $elements = $rs[$pos]; // id of DIV element will start with sub_id and followed with 'b' (because cloned elements on the page have 'c') and with tbl_id // this way content from the database will not be in collision with new content dragged from the left table and each id stays unique $id = $elements[2] . 'b' . $elements[1]; $name = $elements[3]; $class = substr($id, 0, 2); // class name is only first 2 letters from ID print "<div id=\"{$id}\" class=\"redips-drag {$class}\">{$name}</div>"; } // close table cell print '</td>'; } print "</tr>\n"; }
function fetchData() { global $greyVid, $bradyVids, $lastUpdate; $greyVid = sqlQuery("SELECT * FROM Video WHERE creator='C.G.P. Grey' ORDER BY uploaddate DESC LIMIT 1")[0]; $bradyVids = sqlQuery("SELECT * FROM Video WHERE creator='Brady Haran' AND uploaddate > \$1 ORDER BY uploaddate DESC", array($greyVid["uploaddate"])); $lastUpdate = sqlQuery("SELECT * FROM UpdateLog ORDER BY updatedatetime DESC LIMIT 1")[0]['updatedatetime']; }
/** * Retrieve and existing private key based on the public key value and delete it. * This function also garbage collects any "stale/unused" pairs that are older than 5 minutes (300 seconds) * * @param type $pub */ public function load_from_db($pub) { $res = sqlQuery("SELECT private FROM rsa_pairs where public=?", array($pub)); $this->privKey = $res['private']; // Delete this pair, and garbage collect any pairs older than 5 minutes. sqlQuery("DELETE FROM rsa_pairs where public=? OR timestampdiff(second,created,now()) > ?", array($pub, 300)); }
function hist_exam_plan_report($pid, $encounter, $cols, $id) { $cols = 1; // force always 1 column $count = 0; $data = sqlQuery("SELECT * " . "FROM form_hist_exam_plan WHERE " . "id = '{$id}' AND activity = '1'"); if ($data) { print "<table cellpadding='0' cellspacing='0'>\n<tr>\n"; foreach ($data as $key => $value) { if ($key == "id" || $key == "pid" || $key == "user" || $key == "groupname" || $key == "authorized" || $key == "activity" || $key == "date" || $value == "" || $value == "0" || $value == "0.00") { continue; } if ($value == "on") { $value = "yes"; } $key = ucwords(str_replace("_", " ", $key)); print "<td valign='top'><span class='bold'>{$key}: </span><span class='text'>{$value} </span></td>\n"; $count++; if ($count == $cols) { $count = 0; print "</tr>\n<tr>\n"; } } print "</tr>\n</table>\n"; } }
function tableExists_de($tblname) { $row = sqlQuery("SHOW TABLES LIKE '{$tblname}'"); if (empty($row)) { return false; } return true; }
function get_document_by_catg($pid, $doc_catg) { $result = array(); if ($pid and $doc_catg) { $result = sqlQuery("SELECT d.id, d.date, d.url FROM " . "documents AS d, categories_to_documents AS cd, categories AS c " . "WHERE d.foreign_id = ? " . "AND cd.document_id = d.id " . "AND c.id = cd.category_id " . "AND c.name LIKE ? " . "ORDER BY d.date DESC LIMIT 1", array($pid, $doc_catg)); } return $result['id']; }
function section_invite_sendInvite($team, $player, $days, $text) { echo "<center>Invitation sent to player, thank you!</center>"; $text = htmlentities($text); $msg = '<b>' . $_SESSION['callsign'] . "</b> is inviting you to join his/her team: <b>{$team->name}</b>.<br>\n <u>Invitation text:</u><br>{$text}<p><br>\n <a href='index.php?link=jointeam&id={$team->id}'><font size=+1>Click here to accept the invitation.</font></a><br>\n Note that the invitation expires {$days} days from when it was sent."; sendBzMail($_SESSION['playerid'], $player->id, 'Invitation from ' . $_SESSION['callsign'], $msg, false, true); sqlQuery("INSERT INTO bzl_invites (teamid, playerid, expires) VALUES ({$team->id}, {$player->id}, \n ADDDATE(NOW(), INTERVAL {$days} DAY))"); }
/** * Get lab's ID from the users table given its NPI. If none return 0. * * @param string $npi The lab's NPI number as known to the system * @return integer The numeric value of the lab's address book entry */ function getLabID($npi) { $lrow = sqlQuery("SELECT ppid FROM procedure_providers WHERE " . "npi = ? ORDER BY ppid LIMIT 1", array($npi)); if (empty($lrow['ppid'])) { return 0; } return intval($lrow['ppid']); }
function getCopay($patient_id, $encdate) { $tmp = sqlQuery("SELECT provider, copay FROM insurance_data " . "WHERE pid = '{$patient_id}' AND type = 'primary' " . "AND date <= '{$encdate}' ORDER BY date DESC LIMIT 1"); if ($tmp['provider']) { return sprintf('%01.2f', 0 + $tmp['copay']); } return -1; }
public function test(AmcPatient $patient, $beginDate, $endDate) { $off_visits = sqlQuery("select count(encounter) as cnt from form_encounter e inner join openemr_postcalendar_categories opc on opc.pc_catid = e.pc_catid where e.pid = ? and e.date >= ? and e.date <= ? and opc.pc_catname = 'office visit'", array($patient->id, $beginDate, $endDate)); if ($off_visits['cnt'] >= 1) { return true; } return false; }
function row_modify($table, $set, $where) { if (sqlQuery("SELECT * FROM {$table} WHERE {$where}")) { newEvent("deactivate", $_SESSION['authUser'], $_SESSION['authProvider'], 1, "{$table}: {$where}"); $query = "UPDATE {$table} SET {$set} WHERE {$where}"; echo $query . "<br>\n"; sqlStatement($query); } }
/** * Function to return the category id of a category title. * * @param string $category_title category title * @return int/boolean category id (returns false if the category title does not exist) */ function document_category_to_id($category_title) { $ret = sqlQuery("SELECT `id` FROM `categories` WHERE `name`=?", array($category_title)); if ($ret['id']) { return $ret['id']; } else { return false; } }
public function test(AmcPatient $patient, $beginDate, $endDate) { $check = sqlQuery("SELECT dc_father,dc_mother, dc_siblings, dc_offspring FROM `history_data` WHERE `pid`=? ORDER BY id DESC LIMIT 1", array($patient->id)); if ($check['dc_father'] != "" || $check['dc_mother'] != "" || $check['dc_siblings'] != "" || $check['dc_offspring'] != "") { return true; } else { return false; } }
/** * Get a list item title, translating if required. * * @param string $listid List identifier. * @param string $value List item identifier. * @return string The item's title. */ function getListItem($listid, $value) { $lrow = sqlQuery("SELECT title FROM list_options " . "WHERE list_id = ? AND option_id = ?", array($listid, $value)); $tmp = xl_list_label($lrow['title']); if (empty($tmp)) { $tmp = "({$report_status})"; } return $tmp; }
/** * Get a list item title, translating if required. * * @param string $listid List identifier. * @param string $value List item identifier. * @return string The item's title. */ function getListItem($listid, $value) { $lrow = sqlQuery("SELECT title FROM list_options " . "WHERE list_id = ? AND option_id = ? AND activity = 1", array($listid, $value)); $tmp = xl_list_label($lrow['title']); if (empty($tmp)) { $tmp = $value === '' ? '' : "({$value})"; } return $tmp; }
function thisLineItem($row, $codetype, $code) { global $code_types; $provname = $row['provider_lname']; if (!empty($row['provider_fname'])) { $provname .= ', ' . $row['provider_fname']; if (!empty($row['provider_mname'])) { $provname .= ' ' . $row['provider_mname']; } } $crow = sqlQuery("SELECT code_text FROM codes WHERE " . "code_type = '" . $code_types[$codetype]['id'] . "' AND " . "code = '{$code}' LIMIT 1"); $code_text = $crow['code_text']; if ($_POST['form_csvexport']) { echo '"' . addslashes($row['patient_name']) . '",'; echo '"' . addslashes($row['pubpid']) . '",'; echo '"' . addslashes($row['date_ordered']) . '",'; echo '"' . addslashes($row['procedure_name']) . '",'; echo '"' . addslashes($provname) . '",'; echo '"' . addslashes($code) . '",'; echo '"' . addslashes($code_text) . '"' . "\n"; } else { ?> <tr> <td class="detail"><?php echo $row['patient_name']; ?> </td> <td class="detail"><?php echo $row['pubpid']; ?> </td> <td class="detail"><?php echo $row['date_ordered']; ?> </td> <td class="detail"><?php echo $row['procedure_name']; ?> </td> <td class="detail"><?php echo $provname; ?> </td> <td class="detail"><?php echo $code; ?> </td> <td class="detail"><?php echo $code_text; ?> </td> </tr> <?php } // End not csv export }
public function test(AmcPatient $patient, $beginDate, $endDate) { $encQry = "SELECT * FROM forms f " . "INNER JOIN form_encounter fe ON f.encounter = fe.encounter " . "WHERE f.formdir != 'newpatient' AND f.deleted = 0 AND f.pid = ? AND (f.date BETWEEN ? AND ?) "; $check = sqlQuery($encQry, array($patient->id, $beginDate, $endDate)); if (!empty($check)) { return true; } else { return false; } }
public function test(CqmPatient $patient, $beginDate, $endDate) { $riskCatAssessQry = "SELECT count(*) as cnt FROM form_encounter fe " . "INNER JOIN openemr_postcalendar_categories opc ON fe.pc_catid = opc.pc_catid " . "INNER JOIN procedure_order pr ON fe.encounter = pr.encounter_id " . "INNER JOIN procedure_order_code prc ON pr.procedure_order_id = prc.procedure_order_id " . "WHERE opc.pc_catname = 'Office Visit' " . "AND (fe.date BETWEEN ? AND ?) " . "AND fe.pid = ? " . "AND ( prc.procedure_code = '73830-2' OR prc.procedure_code = '57254-5' ) " . "AND prc.procedure_order_title = 'Risk Category Assessment'"; $check = sqlQuery($riskCatAssessQry, array($beginDate, $endDate, $patient->id)); if ($check['cnt'] > 0) { return true; } else { return false; } }