Пример #1
0
 private function setReasonForReferralSection()
 {
     if (isset($this->encounter)) {
         $Referrals = new Referrals();
         $ReferringProviders = new ReferringProviders();
         $referral = $Referrals->getPatientReferralByEid($this->encounter['eid']);
         $referringProvider = $ReferringProviders->getReferringProviderById($referral['refer_to']);
         unset($Referrals, $ReferringProviders);
         $reasonForReferral = ['templateId' => ['@attributes' => ['root' => '1.3.6.1.4.1.19376.1.5.3.1.3.1']], 'code' => ['@attributes' => ['code' => '42349-1', 'codeSystem' => '2.16.840.1.113883.6.1', 'codeSystemName' => 'LOINC', 'displayName' => 'Reason for Referral']], 'title' => 'Reason for Referral', 'text' => $referral['referal_reason'] . ', ' . $referringProvider['title'] . ' ' . $referringProvider['fname'] . ' ' . $referringProvider['lname'] . ', ' . $referringProvider['facilities'][0]['phone_number'] . ', ' . $referringProvider['facilities'][0]['name'] . ', ' . $referringProvider['facilities'][0]['address'] . ' ' . $referringProvider['facilities'][0]['address_cont'] . ', ' . $referringProvider['facilities'][0]['city'] . ' ' . $referringProvider['facilities'][0]['state'] . ' ' . $referringProvider['facilities'][0]['postal_code']];
         $this->addSection(['section' => $reasonForReferral]);
     }
 }
Пример #2
0
     while ($item = SQL::fetch($result)) {
         $rows[] = array('left=' . Skin::build_link($item['referer'], $item['domain'], 'external'), 'left=' . Skin::build_number($item['hits']));
     }
     // render the table
     $referrals .= Skin::table($headers, $rows);
 }
 // display in a separate panel
 if (trim($referrals)) {
     $panels[] = array('referrals', i18n::s('Referrals'), 'referrals_panel', $referrals);
 }
 //
 // requests from search engines
 //
 $searches = '';
 include_once $context['path_to_root'] . 'agents/referrals.php';
 if ($result = Referrals::list_by_keywords(0, 50)) {
     // table row
     $headers = array(i18n::s('Keywords'), i18n::s('Count'));
     // table rows
     $rows = array();
     while ($item = SQL::fetch($result)) {
         $rows[] = array('left=' . Skin::build_link($item['referer'], $item['keywords'], 'external'), 'left=' . Skin::build_number($item['hits']));
     }
     // render the table
     $searches .= Skin::table($headers, $rows);
 }
 // display in a separate panel
 if (trim($searches)) {
     $panels[] = array('searches', i18n::s('Searches'), 'searches_panel', $searches);
 }
 //
Пример #3
0
 }
 // profiles
 include_once '../agents/profiles.php';
 if ($stats = Profiles::stat()) {
     $cells = array();
     $cells[] = SQL::table_name('profiles');
     $cells[] = 'center=' . $stats['count'];
     $cells[] = 'center=--';
     $cells[] = 'center=--';
     $text .= Skin::table_row($cells, $lines++);
 } else {
     $text .= Skin::table_row(array(SQL::table_name('profiles'), i18n::s('unknown or empty table'), ' ', ' '), $lines++);
 }
 // referrals
 include_once '../agents/referrals.php';
 if ($stats = Referrals::stat()) {
     $cells = array();
     $cells[] = SQL::table_name('referrals');
     $cells[] = 'center=' . $stats['count'];
     $cells[] = 'center=--';
     $cells[] = 'center=--';
     $text .= Skin::table_row($cells, $lines++);
 } else {
     $text .= Skin::table_row(array(SQL::table_name('referrals'), i18n::s('unknown or empty table'), ' ', ' '), $lines++);
 }
 // sections
 if ($row = SQL::table_stat('sections')) {
     $cells = array();
     $cells[] = Skin::build_link('sections/', SQL::table_name('sections'), 'basic');
     $cells[] = 'center=' . $row[0];
     $cells[] = 'center=' . ($row[1] ? Skin::build_date($row[1]) : '--');
Пример #4
0
    $menu = array('links/' => i18n::s('Links'));
    $context['text'] .= Skin::build_list($menu, 'menu_bar');
    // normalize referrals
} elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == 'normalize') {
    // scan links
    $context['text'] .= '<p>' . sprintf(i18n::s('Analyzing table %s...'), SQL::table_name('links')) . "</p>\n";
    // process all links, but stop after CHUNK_SIZE updates
    $links_offset = 0;
    $changes = 0;
    while ($changes < MAXIMUM_SIZE) {
        // seek the database and check newest referrals
        include_once '../agents/referrals.php';
        if ($result = Referrals::list_by_dates($links_offset, CHUNK_SIZE)) {
            // analyze each link
            while ($item = SQL::fetch($result)) {
                list($link, $domain, $keywords) = Referrals::normalize($item['referer']);
                // we suppose the referral is already ok
                $ok = TRUE;
                // link has been changed
                if ($item['referer'] != $link) {
                    $context['text'] .= BR . '< ' . htmlspecialchars($item['referer']) . BR . '> ' . htmlspecialchars($link) . BR;
                    $item['referer'] = $link;
                    $ok = FALSE;
                }
                // domain has been changed
                if (!isset($item['domain']) || $item['domain'] != $domain) {
                    if (isset($item['domain']) && $item['domain']) {
                        $context['text'] .= BR . '< ' . htmlspecialchars($item['domain']) . BR . '> ' . htmlspecialchars($domain) . BR;
                    } else {
                        $context['text'] .= BR . 'd ' . htmlspecialchars($domain) . BR;
                    }
Пример #5
0
 /**
  * display the list of referrals
  *
  * @param string script name
  * @return string to be displayed in the extra panel
  */
 public static function &build_referrals($script)
 {
     global $context;
     $output = '';
     if (Surfer::is_associate() || isset($context['with_referrals']) && $context['with_referrals'] == 'Y') {
         $cache_id = $script . '#referrals';
         if (!($output = Cache::get($cache_id))) {
             // box content in a sidebar box
             include_once $context['path_to_root'] . 'agents/referrals.php';
             if ($items = Referrals::list_by_hits_for_url($context['url_to_root_parameter'] . $script)) {
                 $output =& Skin::build_box(i18n::s('Referrals'), $items, 'referrals', 'referrals');
             }
             // save in cache for 5 minutes 60 * 5 = 300
             Cache::put($cache_id, $output, 'stable', 300);
         }
     }
     return $output;
 }
Пример #6
0
 /**
  * process one single HTTP request
  *
  * This function removes any PHPSESSID data in the query string, if any
  *
  * @return void
  *
  * @see agents/referrals_hook.php
  */
 public static function check_request()
 {
     global $context;
     // don't bother with HEAD requests
     if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'HEAD') {
         return;
     }
     // the target url
     if (!isset($_SERVER['REQUEST_URI']) || !($url = $_SERVER['REQUEST_URI'])) {
         return;
     }
     // only remember viewed pages and index pages
     if (!preg_match('/\\/(index|view).php/', $url)) {
         return;
     }
     // continue only if we have a referer
     if (!isset($_SERVER['HTTP_REFERER']) || !($referer = $_SERVER['HTTP_REFERER'])) {
         return;
     }
     // do not memorize cache referrals
     if (preg_match('/cache:/i', $referer)) {
         return;
     }
     // block pernicious attacks
     $referer = strip_tags($referer);
     // only remember external referrals
     if (preg_match('/\\b' . preg_quote(str_replace('www.', '', $context['host_name']), '/') . '\\b/i', $referer)) {
         return;
     }
     // stop crawlers
     if (Surfer::is_crawler()) {
         return;
     }
     // avoid banned sources
     include_once $context['path_to_root'] . 'servers/servers.php';
     if (preg_match(Servers::get_banned_pattern(), $referer)) {
         return;
     }
     // normalize the referral, extract keywords, and domain
     list($referer, $domain, $keywords) = Referrals::normalize($referer);
     // if a record exists for this url
     $query = "SELECT id FROM " . SQL::table_name('referrals') . " AS referrals" . " WHERE referrals.url LIKE '" . SQL::escape($url) . "' AND referrals.referer LIKE '" . SQL::escape($referer) . "'";
     if (!($item = SQL::query_first($query))) {
         return;
     }
     // update figures
     if (isset($item['id'])) {
         $query = "UPDATE " . SQL::table_name('referrals') . " SET" . " hits=hits+1," . " stamp='" . gmstrftime('%Y-%m-%d %H:%M:%S') . "'" . " WHERE id = " . $item['id'];
         // create a new record
     } else {
         // ensure the referer is accessible
         if (($content = http::proceed($referer)) === FALSE) {
             return;
         }
         // we have to find a reference to ourself in this page
         if (strpos($content, $context['url_to_home']) === FALSE) {
             return;
         }
         $query = "INSERT INTO " . SQL::table_name('referrals') . " SET" . " url='" . SQL::escape($url) . "'," . " referer='" . SQL::escape($referer) . "'," . " domain='" . SQL::escape($domain) . "'," . " keywords='" . SQL::escape($keywords) . "'," . " hits=1," . " stamp='" . gmstrftime('%Y-%m-%d %H:%M:%S') . "'";
     }
     // actual database update
     if (SQL::query($query) === FALSE) {
         return;
     }
     // prune with a probability of 1/100
     if (rand(1, 100) != 50) {
         return;
     }
     // purge oldest records -- 100 days = 8640000 seconds
     $query = "DELETE FROM " . SQL::table_name('referrals') . " WHERE stamp < '" . gmstrftime('%Y-%m-%d %H:%M:%S', time() - 8640000) . "'";
     SQL::query($query);
 }
Пример #7
0
 private function addReferralData($params, $tokens, $allNeededInfo)
 {
     $referral = new Referrals();
     $data = $referral->getPatientReferral($params->referralId);
     if ($data === false) {
         return $allNeededInfo;
     }
     $info = ['[REFERRAL_ID]' => $data['id'], '[REFERRAL_DATE]' => $data['referral_date'], '[REFERRAL_REASON]' => $data['referal_reason'], '[REFERRAL_DIAGNOSIS]' => $data['diagnosis_code'] . ' (' . $data['diagnosis_code_type'] . ')', '[REFERRAL_SERVICE]' => $data['service_code'] . ' (' . $data['service_code_type'] . ')', '[REFERRAL_RISK_LEVEL]' => $data['risk_level'], '[REFERRAL_BY_TEXT]' => $data['refer_by_text'], '[REFERRAL_TO_TEXT]' => $data['refer_to_text']];
     unset($referral);
     foreach ($tokens as $i => $tok) {
         if (isset($info[$tok]) && ($allNeededInfo[$i] == '' || $allNeededInfo[$i] == null)) {
             $allNeededInfo[$i] = $info[$tok];
         }
     }
     return $allNeededInfo;
 }