function doSubs($s) { global $ptrow, $hisrow, $enrow, $nextLocation, $keyLocation, $keyLength; global $groupLevel, $groupCount, $itemSeparator, $pid, $encounter; $nextLocation = 0; $groupLevel = 0; $groupCount = 0; while (($keyLocation = strpos($s, '{', $nextLocation)) !== FALSE) { $nextLocation = $keyLocation + 1; if (keySearch($s, '{PatientName}')) { $tmp = $ptrow['fname']; if ($ptrow['mname']) { if ($tmp) { $tmp .= ' '; } $tmp .= $ptrow['mname']; } if ($ptrow['lname']) { if ($tmp) { $tmp .= ' '; } $tmp .= $ptrow['lname']; } $s = keyReplace($s, dataFixup($tmp, xl('Name'))); } else { if (keySearch($s, '{PatientID}')) { $s = keyReplace($s, dataFixup($ptrow['pubpid'], xl('Chart ID'))); } else { if (keySearch($s, '{Address}')) { $s = keyReplace($s, dataFixup($ptrow['street'], xl('Street'))); } else { if (keySearch($s, '{City}')) { $s = keyReplace($s, dataFixup($ptrow['city'], xl('City'))); } else { if (keySearch($s, '{State}')) { $s = keyReplace($s, dataFixup(getListItemTitle('state', $ptrow['state']), xl('State'))); } else { if (keySearch($s, '{Zip}')) { $s = keyReplace($s, dataFixup($ptrow['postal_code'], xl('Postal Code'))); } else { if (keySearch($s, '{PatientPhone}')) { $ptphone = $ptrow['phone_contact']; if (empty($ptphone)) { $ptphone = $ptrow['phone_home']; } if (empty($ptphone)) { $ptphone = $ptrow['phone_cell']; } if (empty($ptphone)) { $ptphone = $ptrow['phone_biz']; } if (preg_match("/([2-9]\\d\\d)\\D*(\\d\\d\\d)\\D*(\\d\\d\\d\\d)/", $ptphone, $tmp)) { $ptphone = '(' . $tmp[1] . ')' . $tmp[2] . '-' . $tmp[3]; } $s = keyReplace($s, dataFixup($ptphone, xl('Phone'))); } else { if (keySearch($s, '{PatientDOB}')) { $s = keyReplace($s, dataFixup(oeFormatShortDate($ptrow['DOB']), xl('Birth Date'))); } else { if (keySearch($s, '{PatientSex}')) { $s = keyReplace($s, dataFixup(getListItemTitle('sex', $ptrow['sex']), xl('Sex'))); } else { if (keySearch($s, '{DOS}')) { $s = keyReplace($s, dataFixup(oeFormatShortDate(substr($enrow['date'], 0, 10)), xl('Service Date'))); } else { if (keySearch($s, '{ChiefComplaint}')) { $cc = $enrow['reason']; $patientid = $ptrow['pid']; $DOS = substr($enrow['date'], 0, 10); // Prefer appointment comment if one is present. $evlist = fetchEvents($DOS, $DOS, " AND pc_pid = ? ", null, false, 0, array($patientid)); foreach ($evlist as $tmp) { if ($tmp['pc_pid'] == $pid && !empty($tmp['pc_hometext'])) { $cc = $tmp['pc_hometext']; } } $s = keyReplace($s, dataFixup($cc, xl('Chief Complaint'))); } else { if (keySearch($s, '{ReferringDOC}')) { $tmp = empty($ptrow['ur_fname']) ? '' : $ptrow['ur_fname']; if (!empty($ptrow['ur_mname'])) { if ($tmp) { $tmp .= ' '; } $tmp .= $ptrow['ur_mname']; } if (!empty($ptrow['ur_lname'])) { if ($tmp) { $tmp .= ' '; } $tmp .= $ptrow['ur_lname']; } $s = keyReplace($s, dataFixup($tmp, xl('Referer'))); } else { if (keySearch($s, '{Allergies}')) { $tmp = generate_plaintext_field(array('data_type' => '24', 'list_id' => ''), ''); $s = keyReplace($s, dataFixup($tmp, xl('Allergies'))); } else { if (keySearch($s, '{Medications}')) { $s = keyReplace($s, dataFixup(getIssues('medication'), xl('Medications'))); } else { if (keySearch($s, '{ProblemList}')) { $s = keyReplace($s, dataFixup(getIssues('medical_problem'), xl('Problem List'))); } else { if (keySearch($s, '{GRP}')) { ++$groupLevel; $groupCount = 0; $s = keyReplace($s, ''); } else { if (keySearch($s, '{/GRP}')) { if ($groupLevel > 0) { --$groupLevel; } $s = keyReplace($s, ''); } else { if (preg_match('/^\\{ITEMSEP\\}(.*?)\\{\\/ITEMSEP\\}/', substr($s, $keyLocation), $matches)) { $itemSeparator = $matches[1]; $keyLength = strlen($matches[0]); $s = keyReplace($s, ''); } else { if (preg_match('/^\\{(LBF\\w+):(\\w+)\\}/', substr($s, $keyLocation), $matches)) { $formname = $matches[1]; $fieldid = $matches[2]; $keyLength = 3 + strlen($formname) + strlen($fieldid); $data = ''; $currvalue = ''; $title = ''; $frow = sqlQuery("SELECT * FROM layout_options " . "WHERE form_id = ? AND field_id = ? LIMIT 1", array($formname, $fieldid)); if (!empty($frow)) { $ldrow = sqlQuery("SELECT ld.field_value " . "FROM lbf_data AS ld, forms AS f WHERE " . "f.pid = ? AND f.encounter = ? AND f.formdir = ? AND f.deleted = 0 AND " . "ld.form_id = f.form_id AND ld.field_id = ? " . "ORDER BY f.form_id DESC LIMIT 1", array($pid, $encounter, $formname, $fieldid)); if (!empty($ldrow)) { $currvalue = $ldrow['field_value']; $title = $frow['title']; } if ($currvalue !== '') { $data = generate_plaintext_field($frow, $currvalue); } } $s = keyReplace($s, dataFixup($data, $title)); } else { if (preg_match('/^\\{(DEM|HIS):(\\w+)\\}/', substr($s, $keyLocation), $matches)) { $formname = $matches[1]; $fieldid = $matches[2]; $keyLength = 3 + strlen($formname) + strlen($fieldid); $data = ''; $currvalue = ''; $title = ''; $frow = sqlQuery("SELECT * FROM layout_options " . "WHERE form_id = ? AND field_id = ? LIMIT 1", array($formname, $fieldid)); if (!empty($frow)) { $tmprow = $formname == 'DEM' ? $ptrow : $hisrow; if (isset($tmprow[$fieldid])) { $currvalue = $tmprow[$fieldid]; $title = $frow['title']; } if ($currvalue !== '') { $data = generate_plaintext_field($frow, $currvalue); } } $s = keyReplace($s, dataFixup($data, $title)); } } } } } } } } } } } } } } } } } } } } } // End if { character found. return $s; }
?> </tr> </table> </div> <div id="searchResults"> <table> <tr> <?php if ($result) { foreach ($result as $iter) { echo "<tr class='oneresult' id='" . htmlspecialchars($iter['pid'], ENT_QUOTES) . "'>"; echo "<td class='srName'>" . htmlspecialchars($iter['lname'] . ", " . $iter['fname']) . "</td>\n"; echo "<td class='srGender'>" . text(getListItemTitle("sex", $iter['sex'])) . "</td>\n"; //other phone number display setup for tooltip $phone_biz = ''; if ($iter["phone_biz"] != "") { $phone_biz = " [business phone " . $iter["phone_biz"] . "] "; } $phone_contact = ''; if ($iter["phone_contact"] != "") { $phone_contact = " [contact phone " . $iter["phone_contact"] . "] "; } $phone_cell = ''; if ($iter["phone_cell"] != "") { $phone_cell = " [cell phone " . $iter["phone_cell"] . "] "; } $all_other_phones = $phone_biz . $phone_contact . $phone_cell; if ($all_other_phones == '') {
/** * Display the clinical summary widget. * * @param integer $patient_id pid of selected patient * @param string $mode choose either 'reminders-all' or 'reminders-due' (required) * @param string $dateTarget target date (format Y-m-d H:i:s). If blank then will test with current date as target. * @param string $organize_mode Way to organize the results (default or plans) * @param string $user If a user is set, then will only show rules that user has permission to see. */ function clinical_summary_widget($patient_id, $mode, $dateTarget = '', $organize_mode = 'default', $user = '') { // Set date to current if not set $dateTarget = $dateTarget ? $dateTarget : date('Y-m-d H:i:s'); // Collect active actions $actions = test_rules_clinic('', 'passive_alert', $dateTarget, $mode, $patient_id, '', $organize_mode, array(), 'primary', NULL, NULL, $user); // Display the actions $current_targets = array(); foreach ($actions as $action) { // Deal with plan names first if (isset($action['is_plan']) && $action['is_plan']) { echo "<br><b>"; echo htmlspecialchars(xl("Plan"), ENT_NOQUOTES) . ": "; echo generate_display_field(array('data_type' => '1', 'list_id' => 'clinical_plans'), $action['id']); echo "</b><br>"; continue; } // Collect the Rule Title, Rule Developer, Rule Funding Source, and Rule Release and show it when hover over the item. $tooltip = ''; if (!empty($action['rule_id'])) { $rule_title = getListItemTitle("clinical_rules", $action['rule_id']); $ruleData = sqlQuery("SELECT `developer`, `funding_source`, `release_version`, `web_reference` " . "FROM `clinical_rules` " . "WHERE `id`=? AND `pid`=0", array($action['rule_id'])); $developer = $ruleData['developer']; $funding_source = $ruleData['funding_source']; $release = $ruleData['release_version']; $web_reference = $ruleData['web_reference']; if (!empty($rule_title)) { $tooltip = xla('Rule Title') . ": " . attr($rule_title) . "
"; } if (!empty($developer)) { $tooltip .= xla('Rule Developer') . ": " . attr($developer) . "
"; } if (!empty($funding_source)) { $tooltip .= xla('Rule Funding Source') . ": " . attr($funding_source) . "
"; } if (!empty($release)) { $tooltip .= xla('Rule Release') . ": " . attr($release); } if (!empty($tooltip) || !empty($web_reference)) { if (!empty($web_reference)) { $tooltip = "<a href='" . attr($web_reference) . "' target='_blank' style='white-space: pre-line;' title='" . $tooltip . "'>?</a>"; } else { $tooltip = "<span style='white-space: pre-line;' title='" . $tooltip . "'>?</span>"; } } } if ($action['custom_flag']) { // Start link for reminders that use the custom rules input screen $url = "../rules/patient_data.php?category=" . htmlspecialchars($action['category'], ENT_QUOTES); $url .= "&item=" . htmlspecialchars($action['item'], ENT_QUOTES); echo "<a href='" . $url . "' class='iframe medium_modal' onclick='top.restoreSession()'>"; } else { if ($action['clin_rem_link']) { // Start link for reminders that use the custom rules input screen $pieces_url = parse_url($action['clin_rem_link']); $url_prefix = $pieces_url['scheme']; if ($url_prefix == 'https' || $url_prefix == 'http') { echo "<a href='" . $action['clin_rem_link'] . "' class='iframe medium_modal' onclick='top.restoreSession()'>"; } else { echo "<a href='../../../" . $action['clin_rem_link'] . "' class='iframe medium_modal' onclick='top.restoreSession()'>"; } } else { // continue since no link is needed } } // Display Reminder Details echo generate_display_field(array('data_type' => '1', 'list_id' => 'rule_action_category'), $action['category']) . ": " . generate_display_field(array('data_type' => '1', 'list_id' => 'rule_action'), $action['item']); if ($action['custom_flag'] || $action['clin_rem_link']) { // End link for reminders that use an html link echo "</a>"; } // Display due status if ($action['due_status']) { // Color code the status (red for past due, purple for due, green for not due and black for soon due) if ($action['due_status'] == "past_due") { echo " (<span style='color:red'>"; } else { if ($action['due_status'] == "due") { echo " (<span style='color:purple'>"; } else { if ($action['due_status'] == "not_due") { echo " (<span style='color:green'>"; } else { echo " (<span>"; } } } echo generate_display_field(array('data_type' => '1', 'list_id' => 'rule_reminder_due_opt'), $action['due_status']) . "</span>)"; } // Display the tooltip if (!empty($tooltip)) { echo " " . $tooltip . "<br>"; } else { echo "<br>"; } // Add the target(and rule id and room for future elements as needed) to the $current_targets array. // Only when $mode is reminders-due if ($mode == "reminders-due" && $GLOBALS['enable_alert_log']) { $target_temp = $action['category'] . ":" . $action['item']; $current_targets[$target_temp] = array('rule_id' => $action['rule_id'], 'due_status' => $action['due_status']); } } // Compare the current with most recent action log (this function will also log the current actions) // Only when $mode is reminders-due if ($mode == "reminders-due" && $GLOBALS['enable_alert_log']) { $new_targets = compare_log_alerts($patient_id, $current_targets, 'clinical_reminder_widget', $_SESSION['authId']); if (!empty($new_targets) && $GLOBALS['enable_cdr_new_crp']) { // If there are new action(s), then throw a popup (if the enable_cdr_new_crp global is turned on) // Note I am taking advantage of a slight hack in order to run javascript within code that // is being passed via an ajax call by using a dummy image. echo '<img src="../../pic/empty.gif" onload="alert(\'' . xls('New Due Clinical Reminders') . '\\n\\n'; foreach ($new_targets as $key => $value) { $category_item = explode(":", $key); $category = $category_item[0]; $item = $category_item[1]; echo generate_display_field(array('data_type' => '1', 'list_id' => 'rule_action_category'), $category) . ': ' . generate_display_field(array('data_type' => '1', 'list_id' => 'rule_action'), $item) . '\\n'; } echo '\\n' . '(' . xls('See the Clinical Reminders widget for more details') . ')'; echo '\');this.parentNode.removeChild(this);" />'; } } }
'; </script> </head> <body class="body_top"> <center> <h2> <?php echo xlt('Educational materials for'); echo ' ' . text($codetype) . ' '; echo xlt('code'); echo ' "' . text($codevalue) . '"'; if ($language) { echo ' ' . xlt('with preferred language') . ' ' . text(getListItemTitle('language', $_REQUEST['language'])); } ?> </h2> <?php if ($errmsg) { echo "<p style='color:red'>" . text($errmsg) . "</p>\n"; } ?> <form method='post' action='education.php'> <input type='hidden' name='type' value='<?php echo attr($codetype); ?>
$alert_time = '0'; $alert_color = $colorevents['color']; $alert_time = $colorevents['time_alert']; if (is_checkin($track_stat) || is_checkout($track_stat)) { #bold the check in and check out times in this block. ?> <td class="detail"><b> <?php } else { ?> <td class="detail"> <?php } echo getListItemTitle("apptstat", $track_stat); ?> </b></td> <?php if (is_checkin($track_stat) || is_checkout($track_stat)) { #bold the check in and check out times in this block. ?> <td class="detail"><b> <?php echo text(substr($tracker_elements[$i][start_datetime], 11)); ?> </b></td> <?php } else { ?>
function generate_result_row(&$ctx, &$row, &$rrow, $priors_omitted = false) { $lab_id = empty($row['lab_id']) ? 0 : $row['lab_id'] + 0; $order_type_id = empty($row['order_type_id']) ? 0 : $row['order_type_id'] + 0; $order_seq = empty($row['procedure_order_seq']) ? 0 : $row['procedure_order_seq'] + 0; $report_id = empty($row['procedure_report_id']) ? 0 : $row['procedure_report_id'] + 0; $procedure_code = empty($row['procedure_code']) ? '' : $row['procedure_code']; $procedure_name = empty($row['procedure_name']) ? '' : $row['procedure_name']; $date_report = empty($row['date_report']) ? '' : substr($row['date_report'], 0, 16); $date_report_suf = empty($row['date_report_tz']) ? '' : ' ' . $row['date_report_tz']; $date_collected = empty($row['date_collected']) ? '' : substr($row['date_collected'], 0, 16); $date_collected_suf = empty($row['date_collected_tz']) ? '' : ' ' . $row['date_collected_tz']; $specimen_num = empty($row['specimen_num']) ? '' : $row['specimen_num']; $report_status = empty($row['report_status']) ? '' : $row['report_status']; $review_status = empty($row['review_status']) ? 'received' : $row['review_status']; $report_noteid = ''; if ($report_id && !isset($ctx['seen_report_ids'][$report_id])) { $ctx['seen_report_ids'][$report_id] = true; if ($review_status != 'reviewed') { if ($ctx['sign_list']) { $ctx['sign_list'] .= ','; } $ctx['sign_list'] .= $report_id; } // Allowing for multiple report notes separated by newlines. if (!empty($row['report_notes'])) { $notes = explode("\n", $row['report_notes']); foreach ($notes as $note) { if ($note === '') { continue; } if ($report_noteid) { $report_noteid .= ', '; } $report_noteid .= 1 + storeNote($note); } } } // allow for 0 to be displayed as a result value if ($rrow['result'] == '' && $rrow['result'] !== 0 && $rrow['result'] !== '0') { $result_result = ''; } else { $result_result = $rrow['result']; } $result_code = empty($rrow['result_code']) ? '' : $rrow['result_code']; $result_text = empty($rrow['result_text']) ? '' : $rrow['result_text']; $result_abnormal = empty($rrow['abnormal']) ? '' : $rrow['abnormal']; $result_units = empty($rrow['units']) ? '' : $rrow['units']; $result_facility = empty($rrow['facility']) ? '' : $rrow['facility']; $result_comments = empty($rrow['comments']) ? '' : $rrow['comments']; $result_range = empty($rrow['range']) ? '' : $rrow['range']; $result_status = empty($rrow['result_status']) ? '' : $rrow['result_status']; $result_document_id = empty($rrow['document_id']) ? '' : $rrow['document_id']; // Someone changed the delimiter in result comments from \n to \r. // Have to make sure results are consistent with those before that change. $result_comments = str_replace("\r", "\n", $result_comments); if ($i = strpos($result_comments, "\n")) { // "=" is not a mistake! // If the first line of comments is not empty, then it is actually a long textual // result value with lines delimited by "~" characters. $result_comments = str_replace("~", "\n", substr($result_comments, 0, $i)) . substr($result_comments, $i); } $result_comments = trim($result_comments); $result_noteid = ''; if (!empty($result_comments)) { $result_noteid = 1 + storeNote($result_comments); } if ($priors_omitted) { if ($result_noteid) { $result_noteid .= ', '; } $result_noteid .= 1 + storeNote(xl('This is the latest of multiple result values.')); $ctx['priors_omitted'] = true; } // If a performing organization is provided, make a note for it also. $result_facility = trim(str_replace("\r", "\n", $result_facility)); if ($result_facility) { if ($result_noteid) { $result_noteid .= ', '; } $result_noteid .= 1 + storeNote(xl('Performing organization') . ":\n" . $result_facility); } if ($ctx['lastpcid'] != $order_seq) { ++$ctx['encount']; } $bgcolor = "#" . ($ctx['encount'] & 1 ? "ddddff" : "ffdddd"); echo " <tr class='detail' bgcolor='{$bgcolor}'>\n"; if ($ctx['lastpcid'] != $order_seq) { $ctx['lastprid'] = -1; // force report fields on first line of each procedure $tmp = text("{$procedure_code}: {$procedure_name}"); // Get the LOINC code if one exists in the compendium for this order type. if (empty($GLOBALS['PATIENT_REPORT_ACTIVE'])) { $trow = sqlQuery("SELECT standard_code FROM procedure_type WHERE " . "lab_id = ? AND procedure_code = ? AND procedure_type = 'ord' " . "ORDER BY procedure_type_id LIMIT 1", array($lab_id, $procedure_code)); if (!empty($trow['standard_code'])) { $tmp = "<a href='javascript:educlick(\"LOINC\",\"" . attr($trow['standard_code']) . "\")'>{$tmp}</a>"; } } echo " <td>{$tmp}</td>\n"; } else { echo " <td style='background-color:transparent'> </td>"; } // If this starts a new report or a new order, generate the report fields. if ($report_id != $ctx['lastprid']) { echo " <td>"; echo myCellText(oeFormatShortDate(substr($date_report, 0, 10)) . substr($date_report, 10) . $date_report_suf); echo "</td>\n"; echo " <td>"; echo myCellText(oeFormatShortDate(substr($date_collected, 0, 10)) . substr($date_collected, 10) . $date_collected_suf); echo "</td>\n"; echo " <td>"; echo myCellText($specimen_num); echo "</td>\n"; echo " <td title='" . xla('Check mark indicates reviewed') . "'>"; echo myCellText(getListItem('proc_rep_status', $report_status)); if ($row['review_status'] == 'reviewed') { echo " ✓"; // unicode check mark character } echo "</td>\n"; echo " <td align='center'>"; echo myCellText($report_noteid); echo "</td>\n"; } else { echo " <td colspan='5' style='background-color:transparent'> </td>\n"; } if ($result_code !== '' || $result_document_id) { $tmp = myCellText($result_code); if (empty($GLOBALS['PATIENT_REPORT_ACTIVE']) && !empty($result_code)) { $tmp = "<a href='javascript:educlick(\"LOINC\",\"" . attr($result_code) . "\")'>{$tmp}</a>"; } echo " <td>{$tmp}</td>\n"; echo " <td>"; echo myCellText($result_text); echo "</td>\n"; echo " <td>"; $tmp = myCellText(getListItem('proc_res_abnormal', $result_abnormal)); if ($result_abnormal && strtolower($result_abnormal) != 'no') { echo "<b><font color='red'>{$tmp}</font></b>"; } else { echo $tmp; } echo "</td>\n"; // if ($result_document_id) { $d = new Document($result_document_id); echo " <td colspan='3'>"; if (empty($GLOBALS['PATIENT_REPORT_ACTIVE'])) { echo "<a href='" . $GLOBALS['webroot'] . "/controller.php?document"; echo "&retrieve&patient_id={$patient_id}&document_id={$result_document_id}' "; echo "onclick='top.restoreSession()'>"; } echo $d->get_url_file(); if (empty($GLOBALS['PATIENT_REPORT_ACTIVE'])) { echo "</a>"; } echo "</td>\n"; } else { echo " <td>"; echo myCellText($result_result); echo "</td>\n"; echo " <td>"; echo myCellText($result_range); echo "</td>\n"; echo " <td>"; // Units comes from the lab so might not match anything in the proc_unit list, // but in that case the call will return the same value. echo myCellText(getListItemTitle('proc_unit', $result_units)); echo "</td>\n"; } echo " <td align='center'>"; echo myCellText($result_noteid); echo "</td>\n"; } else { echo " <td colspan='7' style='background-color:transparent'> </td>\n"; } echo " </tr>\n"; $ctx['lastpcid'] = $order_seq; $ctx['lastprid'] = $report_id; ++$ctx['lino']; }
// Display the form // Collect and trim variables $category = trim($_GET['category']); $item = trim($_GET['item']); if (isset($_GET['entryID'])) { $entryID = trim($_GET['entryID']); } // Collect data if a specific entry is selected if (isset($entryID)) { $selectedEntry = sqlQuery("SELECT `date`, `complete`, `result` " . "FROM `rule_patient_data` " . "WHERE `id`=?", array($entryID)); $form_date = $selectedEntry['date']; $form_complete = $selectedEntry['complete']; $form_result = $selectedEntry['result']; } if (isset($_GET['rule'])) { $rule_title = getListItemTitle("clinical_rules", $_GET['rule']); $ruleData = sqlQuery("SELECT `developer`, `funding_source`, `release_version` " . "FROM `clinical_rules` " . "WHERE `id`=? AND `pid`=0", array($_GET['rule'])); $developer = $ruleData['developer']; $funding_source = $ruleData['funding_source']; $release = $ruleData['release_version']; } ?> <table cellspacing='0' cellpadding='0' border='0'> <tr> <td><span class="title"><?php echo generate_display_field(array('data_type' => '1', 'list_id' => 'rule_action_category'), $category) . " - " . generate_display_field(array('data_type' => '1', 'list_id' => 'rule_action'), $item); ?> </span> </td> <td><a href="javascript:submitme();" class="css_button"><span><?php echo htmlspecialchars(xl('Save'), ENT_NOQUOTES); ?>
# calls popup for add edit calendar event ?> )"> <?php } else { ?> <a href="" onclick="return bpopup(<?php echo attr($tracker_id); # calls popup for patient tracker status ?> )"> <?php } ?> <?php echo text(getListItemTitle("apptstat", $status)); # drop down list for appointment status ?> </a> </td> <?php #time in current status $to_time = strtotime(date("Y-m-d H:i:s")); $yestime = '0'; if (strtotime($newend) != '') { $from_time = strtotime($newarrive); $to_time = strtotime($newend); $yestime = '0'; } else { $from_time = strtotime($appointment['start_datetime']);
/** * Display the clinical summary widget. * * @param integer $patient_id pid of selected patient * @param string $mode choose either 'reminders-all' or 'reminders-due' (required) * @param string $dateTarget target date (format Y-m-d H:i:s). If blank then will test with current date as target. * @param string $organize_mode Way to organize the results (default or plans) */ function clinical_summary_widget($patient_id, $mode, $dateTarget = '', $organize_mode = 'default') { // Set date to current if not set $dateTarget = $dateTarget ? $dateTarget : date('Y-m-d H:i:s'); // Collect active actions $actions = test_rules_clinic('', 'passive_alert', $dateTarget, $mode, $patient_id, '', $organize_mode); // Display the actions foreach ($actions as $action) { // Deal with plan names first if (isset($action['is_plan']) && $action['is_plan']) { echo "<br><b>"; echo htmlspecialchars(xl("Plan"), ENT_NOQUOTES) . ": "; echo generate_display_field(array('data_type' => '1', 'list_id' => 'clinical_plans'), $action['id']); echo "</b><br>"; continue; } // Collect the Rule Title, Rule Developer, Rule Funding Source, and Rule Release and show it when hover over the item. $tooltip = ''; if (!empty($action['rule_id'])) { $rule_title = getListItemTitle("clinical_rules", $action['rule_id']); $ruleData = sqlQuery("SELECT `developer`, `funding_source`, `release_version`, `web_reference` " . "FROM `clinical_rules` " . "WHERE `id`=? AND `pid`=0", array($action['rule_id'])); $developer = $ruleData['developer']; $funding_source = $ruleData['funding_source']; $release = $ruleData['release_version']; $web_reference = $ruleData['web_reference']; if (!empty($rule_title)) { $tooltip = xla('Rule Title') . ": " . attr($rule_title) . "
"; } if (!empty($developer)) { $tooltip .= xla('Rule Developer') . ": " . attr($developer) . "
"; } if (!empty($funding_source)) { $tooltip .= xla('Rule Funding Source') . ": " . attr($funding_source) . "
"; } if (!empty($release)) { $tooltip .= xla('Rule Release') . ": " . attr($release); } if (!empty($tooltip) || !empty($web_reference)) { if (!empty($web_reference)) { $tooltip = "<a href='" . attr($web_reference) . "' target='_blank' style='white-space: pre-line;' title='" . $tooltip . "'>?</a>"; } else { $tooltip = "<span style='white-space: pre-line;' title='" . $tooltip . "'>?</span>"; } } } if ($action['custom_flag']) { // Start link for reminders that use the custom rules input screen $url = "../rules/patient_data.php?category=" . htmlspecialchars($action['category'], ENT_QUOTES); $url .= "&item=" . htmlspecialchars($action['item'], ENT_QUOTES); echo "<a href='" . $url . "' class='iframe medium_modal' onclick='top.restoreSession()'>"; } else { if ($action['clin_rem_link']) { // Start link for reminders that use the custom rules input screen $pieces_url = parse_url($action['clin_rem_link']); $url_prefix = $pieces_url['scheme']; if ($url_prefix == 'https' || $url_prefix == 'http') { echo "<a href='" . $action['clin_rem_link'] . "' class='iframe medium_modal' onclick='top.restoreSession()'>"; } else { echo "<a href='../../../" . $action['clin_rem_link'] . "' class='iframe medium_modal' onclick='top.restoreSession()'>"; } } else { // continue since no link is needed } } // Display Reminder Details echo generate_display_field(array('data_type' => '1', 'list_id' => 'rule_action_category'), $action['category']) . ": " . generate_display_field(array('data_type' => '1', 'list_id' => 'rule_action'), $action['item']); if ($action['custom_flag'] || $action['clin_rem_link']) { // End link for reminders that use an html link echo "</a>"; } // Display due status if ($action['due_status']) { // Color code the status (red for past due, purple for due, green for not due and black for soon due) if ($action['due_status'] == "past_due") { echo " (<span style='color:red'>"; } else { if ($action['due_status'] == "due") { echo " (<span style='color:purple'>"; } else { if ($action['due_status'] == "not_due") { echo " (<span style='color:green'>"; } else { echo " (<span>"; } } } echo generate_display_field(array('data_type' => '1', 'list_id' => 'rule_reminder_due_opt'), $action['due_status']) . "</span>)"; } // Display the tooltip if (!empty($tooltip)) { echo " " . $tooltip . "<br>"; } else { echo "<br>"; } } }
<td class="detail" align="center"> <?php echo getListItemTitle('patient_flow_board_rooms', $appt_room);?> </td> <td class="detail" align="center"> <?php echo text($appt_time) ?> </td> <td class="detail" align="center"> <?php echo text(substr($newarrive,11)); ?> </td> <td class="detail" align="center"> <?php if (empty($tracker_id)) { #for appt not yet with tracker id and for recurring appt ?> <a href="" onclick="return calendarpopup(<?php echo attr($appt_eid).",".attr($date_squash); # calls popup for add edit calendar event?>)"> <?php } else { ?> <a href="" onclick="return bpopup(<?php echo attr($tracker_id); # calls popup for patient tracker status?>)"> <?php } ?> <?php echo text(getListItemTitle("apptstat",$status)); # drop down list for appointment status?> </a> </td> <?php #time in current status $to_time = strtotime(date("Y-m-d H:i:s")); $yestime = '0'; if (strtotime($newend) != '') { $from_time = strtotime($newarrive); $to_time = strtotime($newend); $yestime = '0'; } else { $from_time = strtotime($appointment['start_datetime']);
$target = $catAndTarget[1]; echo "<span title='" . attr($rule_title) . "'>" . generate_display_field(array('data_type' => '1', 'list_id' => 'rule_action_category'), $category) . ": " . generate_display_field(array('data_type' => '1', 'list_id' => 'rule_action'), $target) . " (" . generate_display_field(array('data_type' => '1', 'list_id' => 'rule_reminder_due_opt'), $alert['due_status']) . ")" . "<span><br>"; } else { // $row['category'] == 'allergy_alert' echo $alert . "<br>"; } } ?> </td> <td> <?php if (!empty($row['new_value'])) { //list new targets with rule information shown when hover foreach ($new_alerts as $targetInfo => $alert) { if ($row['category'] == 'clinical_reminder_widget' || $row['category'] == 'active_reminder_popup') { $rule_title = getListItemTitle("clinical_rules", $alert['rule_id']); $catAndTarget = explode(':', $targetInfo); $category = $catAndTarget[0]; $target = $catAndTarget[1]; echo "<span title='" . attr($rule_title) . "'>" . generate_display_field(array('data_type' => '1', 'list_id' => 'rule_action_category'), $category) . ": " . generate_display_field(array('data_type' => '1', 'list_id' => 'rule_action'), $target) . " (" . generate_display_field(array('data_type' => '1', 'list_id' => 'rule_reminder_due_opt'), $alert['due_status']) . ")" . "<span><br>"; } else { // $row['category'] == 'allergy_alert' echo $alert . "<br>"; } } } else { echo " "; } ?> </td> </tr>
function doSubs($s) { global $ptrow, $enrow; // $loopcount avoids infinite looping if we screw up. // for ($loopcount = 0; $loopcount < 500; ++$loopcount) { if (keySearch($s, '{PatientName}')) { $tmp = $ptrow['fname']; if ($ptrow['mname']) { if ($tmp) { $tmp .= ' '; } $tmp .= $ptrow['mname']; } if ($ptrow['lname']) { if ($tmp) { $tmp .= ' '; } $tmp .= $ptrow['lname']; } $s = keyReplace($s, $tmp); } else { if (keySearch($s, '{PatientID}')) { $s = keyReplace($s, $ptrow['pubpid']); } else { if (keySearch($s, '{Address}')) { $s = keyReplace($s, $ptrow['street']); } else { if (keySearch($s, '{City}')) { $s = keyReplace($s, $ptrow['city']); } else { if (keySearch($s, '{State}')) { $s = keyReplace($s, getListItemTitle('state', $ptrow['state'])); } else { if (keySearch($s, '{Zip}')) { $s = keyReplace($s, $ptrow['postal_code']); } else { if (keySearch($s, '{PatientPhone}')) { $ptphone = $ptrow['phone_contact']; if (empty($ptphone)) { $ptphone = $ptrow['phone_home']; } if (empty($ptphone)) { $ptphone = $ptrow['phone_cell']; } if (empty($ptphone)) { $ptphone = $ptrow['phone_biz']; } if (preg_match("/([2-9]\\d\\d)\\D*(\\d\\d\\d)\\D*(\\d\\d\\d\\d)/", $ptphone, $tmp)) { $ptphone = '(' . $tmp[1] . ')' . $tmp[2] . '-' . $tmp[3]; } $s = keyReplace($s, $ptphone); } else { if (keySearch($s, '{PatientDOB}')) { $s = keyReplace($s, oeFormatShortDate($ptrow['DOB'])); } else { if (keySearch($s, '{PatientSex}')) { $s = keyReplace($s, getListItemTitle('sex', $ptrow['sex'])); } else { if (keySearch($s, '{DOS}')) { $s = keyReplace($s, oeFormatShortDate(substr($enrow['date'], 0, 10))); } else { if (keySearch($s, '{ChiefComplaint}')) { $cc = $enrow['reason']; $patientid = $ptrow['pid']; $DOS = substr($enrow['date'], 0, 10); // Prefer appointment comment if one is present. $evlist = fetchEvents($DOS, $DOS, " AND pc_pid = '{$patientid}' "); foreach ($evlist as $tmp) { if ($tmp['pc_pid'] == $pid && !empty($tmp['pc_hometext'])) { $cc = $tmp['pc_hometext']; } } $s = keyReplace($s, $cc); } else { if (keySearch($s, '{ReferringDOC}')) { $tmp = empty($ptrow['ur_fname']) ? '' : $ptrow['ur_fname']; if (!empty($ptrow['ur_mname'])) { if ($tmp) { $tmp .= ' '; } $tmp .= $ptrow['ur_mname']; } if (!empty($ptrow['ur_lname'])) { if ($tmp) { $tmp .= ' '; } $tmp .= $ptrow['ur_lname']; } $s = keyReplace($s, $tmp); } else { if (keySearch($s, '{Allergies}')) { $tmp = generate_plaintext_field(array('data_type' => '24', 'list_id' => ''), ''); $s = keyReplace($s, $tmp); } else { if (keySearch($s, '{ProblemList}')) { $tmp = ''; $query = "SELECT title FROM lists WHERE " . "pid = ? AND type = 'medical_problem' AND enddate IS NULL " . "ORDER BY begdate"; $lres = sqlStatement($query, array($GLOBALS['pid'])); $count = 0; while ($lrow = sqlFetchArray($lres)) { if ($count++) { $tmp .= "; "; } $tmp .= $lrow['title']; } $s = keyReplace($s, $tmp); } else { break; } } } } } } } } } } } } } } } return $s; }
$OSPRISM = $data['CTLOSPRISM']; $ODBC = $data['CTLODBC']; $ODDIAM = $data['CTLODDIAM']; $ODADD = $data['CTLODADD']; $ODVA = $data['CTLODVA']; $OSBC = $data['CTLOSBC']; $OSDIAM = $data['CTLOSDIAM']; $OSADD = $data['CTLOSADD']; $OSVA = $data['CTLOSVA']; $COMMENTS = $data['CTL_COMMENTS']; $CTLMANUFACTUREROD = getListItemTitle('CTLManufacturer', $data['CTLMANUFACTUREROD']); $CTLMANUFACTUREROS = getListItemTitle('CTLManufacturer', $data['CTLMANUFACTUREROS']); $CTLSUPPLIEROD = getListItemTitle('CTLManufacturer', $data['CTLSUPPLIEROD']); $CTLSUPPLIEROS = getListItemTitle('CTLManufacturer', $data['CTLSUPPLIEROS']); $CTLBRANDOD = getListItemTitle('CTLManufacturer', $data['CTLBRANDOD']); $CTLBRANDOS = getListItemTitle('CTLManufacturer', $data['CTLBRANDOS']); } //Since we selected the Print Icon, we must be dispensing this - add to dispensed table now $table_name = "form_eye_mag_dispense"; $query = "show columns from " . $table_name; $dispense_fields = sqlStatement($query); $fields = array(); if (sqlNumRows($dispense_fields) > 0) { while ($row = sqlFetchArray($dispense_fields)) { //exclude critical columns/fields, define below as needed if ($row['Field'] == 'id' || $row['Field'] == 'pid' || $row['Field'] == 'user' || $row['Field'] == 'groupname' || $row['Field'] == 'authorized' || $row['Field'] == 'activity' || $row['Field'] == 'RXTYPE' || $row['Field'] == 'REFDATE') { continue; } if (isset(${$row['Field']})) { $fields[$row['Field']] = ${$row['Field']}; }