Example #1
0
 public static function makeCode($data)
 {
     $codes = new Codes();
     foreach ($data as $key => $value) {
         $codes->{$key} = $value;
     }
     $codes->save();
     return 1;
 }
Example #2
0
 function use_buycodes()
 {
     Load::model('codes');
     Load::model('transaction');
     $Codes = new Codes();
     $Transaction = new Transaction();
     if ($_POST['source'] == "Commission Deduction") {
         $Transaction->add_buycodes($_POST['amount']);
         $Codes->add($_POST['howmany'], $_POST['acc_type']);
     } else {
         $Transaction->add_buycodes_request($_POST['howmany'], $_POST['acc_type'], $_POST['amount']);
     }
     echo 1;
     exit;
 }
Example #3
0
 public function render($matches)
 {
     $text = '';
     list($variant, $data) = $matches;
     $text = self::render_chart(Codes::fix_tags($data), $variant);
     return $text;
 }
Example #4
0
 public function doPatientCheck(RsPatient $patient, $beginDate = null, $endDate = null, $options = null)
 {
     $data = Codes::lookup($this->getOptionId());
     $range = new Range(Range::NEG_INF, Range::POS_INF);
     if (isset($options[self::OPTION_RANGE]) && is_a($options[self::OPTION_RANGE], 'Range')) {
         $range = $options[self::OPTION_RANGE];
     }
     foreach ($data as $codeType => $codes) {
         foreach ($codes as $code) {
             // search through vitals to find the most recent lab result in the date range
             // if the result value is within range using Range->test(val), return true
             $sql = "SELECT procedure_result.result, procedure_result.date " . "FROM `procedure_type`, " . "`procedure_order`, " . "`procedure_report`, " . "`procedure_result` " . "WHERE procedure_type.procedure_type_id = procedure_order.procedure_type_id " . "AND procedure_order.procedure_order_id = procedure_report.procedure_order_id " . "AND procedure_report.procedure_report_id = procedure_result.procedure_report_id " . "AND ( procedure_type.standard_code = ? OR procedure_type.procedure_code = ? ) " . "AND procedure_report.date_collected >= ?  " . "AND procedure_report.date_collected <= ?  " . "AND procedure_order.patient_id = ? ";
             if ($range->lowerBound != Range::NEG_INF) {
                 $sql .= "AND procedure_result.result >= ? ";
             }
             if ($range->upperBound != Range::POS_INF) {
                 $sql .= "AND procedure_result.result < ? ";
             }
             $bindings = array($codeType . ':' . $code, $code, $beginDate, $endDate, $patient->id);
             if ($range->lowerBound != Range::NEG_INF) {
                 $bindings[] = $range->lowerBound;
             }
             if ($range->upperBound != Range::POS_INF) {
                 $bindings[] = $range->upperBound;
             }
             $result = sqlStatement($sql, $bindings);
             $number = sqlNumRows($result);
             if ($number > 0) {
                 return true;
             }
         }
     }
     return false;
 }
Example #5
0
 public function doPatientCheck(RsPatient $patient, $beginDate = null, $endDate = null, $options = null)
 {
     $return = false;
     $listOptions = Codes::lookup($this->getOptionId(), 'CVX');
     if (count($listOptions) > 0) {
         $sqlQueryBind = array();
         $query = "SELECT * " . "FROM immunizations " . "WHERE patient_id = ? AND added_erroneously = '0' " . "AND administered_date >= ? " . "AND administered_date <= ? ";
         $query .= "AND ( ";
         $count = 0;
         array_push($sqlQueryBind, $patient->id, $beginDate, $endDate);
         foreach ($listOptions as $option_id) {
             $query .= "cvx_code = ? ";
             $count++;
             if ($count < count($listOptions)) {
                 $query .= "OR ";
             }
             array_push($sqlQueryBind, $option_id);
         }
         $query .= " ) ";
         $result = sqlStatement($query, $sqlQueryBind);
         $rows = array();
         for ($iter = 0; $row = sqlFetchArray($result); $iter++) {
             $rows[$iter] = $row;
         }
         if (isset($options[self::OPTION_COUNT]) && count($rows) >= $options[self::OPTION_COUNT]) {
             $return = true;
         } else {
             if (!isset($options[self::OPTION_COUNT]) && count($rows) > 0) {
                 $return = true;
             }
         }
     }
     return $return;
 }
Example #6
0
 /**
  * list users
  *
  * @param resource the SQL result
  * @return string the rendered text
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // empty list
     if (!SQL::count($result)) {
         $output = array();
         return $output;
     }
     // we return an array of ($url => $attributes)
     $items = array();
     // process all items in the list
     while ($item = SQL::fetch($result)) {
         // we need some address
         if (!$item['email']) {
             continue;
         }
         // do not write to myself
         // 			if($item['id'] == Surfer::get_id())
         // 				continue;
         $label = ucfirst(trim(Codes::beautify(strip_tags($item['full_name'], '<br><div><img><p><span>'))));
         if (!$label) {
             $label = ucfirst($item['nick_name']);
         }
         // one entry per address
         $items[trim($item['email'])] = $label;
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
Example #7
0
 /**
  * list articles
  *
  * @param resource the SQL result
  * @return string the rendered text
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // we return some text
     $text = '';
     // empty list
     if (!SQL::count($result)) {
         return $text;
     }
     // clear flows
     $text .= '<br style="clear: left" />';
     // process all items in the list
     while ($item = SQL::fetch($result)) {
         // get the related overlay
         $overlay = Overlay::load($item, 'article:' . $item['id']);
         // the url to view this item
         $url = Articles::get_permalink($item);
         // use the title to label the link
         if (is_object($overlay)) {
             $title = Codes::beautify_title($overlay->get_text('title', $item));
         } else {
             $title = Codes::beautify_title($item['title']);
         }
         // the hovering title
         if ($item['introduction'] && $context['skins_with_details'] == 'Y') {
             $hover = strip_tags(Codes::beautify_introduction($item['introduction']));
         } else {
             $hover = i18n::s('View the page');
         }
         // title is a link to the target article
         $title =& Skin::build_link($url, $title, 'basic', $hover);
         // use the thumbnail for this article
         if ($icon = trim($item['thumbnail_url'])) {
             // fix relative path
             if (!preg_match('/^(\\/|http:|https:|ftp:)/', $icon)) {
                 $icon = $context['url_to_root'] . $icon;
             }
             // use parameter of the control panel for this one
             $options = '';
             if (isset($context['classes_for_thumbnail_images'])) {
                 $options = 'class="' . $context['classes_for_thumbnail_images'] . '" ';
             }
             // build the complete HTML element
             $icon = '<img src="' . $icon . '" alt="" title="' . encode_field($hover) . '" ' . $options . ' />';
             // use default icon if nothing to display
         } else {
             $icon = MAP_IMG;
         }
         // use the image as a link to the target page
         $icon =& Skin::build_link($url, $icon, 'basic', $hover);
         // add a floating box
         $text .= Skin::build_box($title, $icon, 'floating');
     }
     // clear flows
     $text .= '<br style="clear: left" />';
     // end of processing
     SQL::free($result);
     return $text;
 }
Example #8
0
 /**
  * list images
  *
  * @param resource the SQL result
  * @return string the rendered text
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // empty list
     if (!SQL::count($result)) {
         $output = array();
         return $output;
     }
     // we return an array of ($url => $attributes)
     $items = array();
     // process all items in the list
     while ($item = SQL::fetch($result)) {
         // get the anchor for this image
         if ($item['anchor']) {
             $anchor = Anchors::get($item['anchor']);
         }
         // url to view the image
         $url = $context['url_to_home'] . $context['url_to_root'] . Images::get_url($item['id']);
         // time of last update
         $time = SQL::strtotime($item['edit_date']);
         // the title as the label
         if ($item['title']) {
             $label = ucfirst($item['title']) . ' (' . $item['image_name'] . ')';
         } else {
             $label = $item['image_name'];
         }
         // the section
         $section = '';
         if (is_object($anchor)) {
             $section = ucfirst($anchor->get_title());
         }
         // the author(s) is an e-mail address, according to rss 2.0 spec
         $author = $item['create_address'] . ' (' . $item['create_name'] . ')';
         if ($item['create_address'] != $item['edit_address']) {
             if ($author) {
                 $author .= ', ';
             }
             $author .= $item['edit_address'] . ' (' . $item['edit_name'] . ')';
         }
         // the description
         $description = Codes::beautify($item['description']);
         // cap the number of words
         $description = Skin::cap($description, 300);
         // fix image references
         $description = preg_replace('#"/([^">]+?)"#', '"' . $context['url_to_home'] . '/$1"', $description);
         $introduction = $description;
         // other rss fields
         $extensions = array();
         // url for enclosure
         $type = Files::get_mime_type($item['image_name']);
         $extensions[] = '<enclosure url="' . $context['url_to_home'] . $context['url_to_root'] . Files::get_path($item['anchor'], 'images') . '/' . $item['image_name'] . '"' . ' length="' . $item['image_size'] . '"' . ' type="' . $type . '" />';
         // list all components for this item
         $items[$url] = array($time, $label, $author, $section, NULL, $introduction, $description, $extensions);
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
Example #9
0
 /**
  * list comments as successive notes in a thread
  *
  * @param resource the SQL result
  * @return string the rendered text
  **/
 function layout($result)
 {
     global $context;
     // we return formatted text
     $text = '';
     // empty list
     if (!SQL::count($result)) {
         return $text;
     }
     // build a list of comments
     while ($item = SQL::fetch($result)) {
         // automatic notification
         if ($item['type'] == 'notification') {
             $text = '<dd class="thread_other" style="font-style: italic;">' . ucfirst(trim($item['description'])) . '</dd>' . $text;
         } else {
             // link to user profile -- open links in separate window to enable side browsing of participant profiles
             if ($item['create_id']) {
                 if ($user = Users::get($item['create_id']) && $user['full_name']) {
                     $hover = $user['full_name'];
                 } else {
                     $hover = NULL;
                 }
                 $author = Users::get_link($item['create_name'], $item['create_address'], $item['create_id'], TRUE, $hover);
             } else {
                 $author = Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id'], TRUE);
             }
             // differentiate my posts from others
             if (Surfer::get_id() && $item['create_id'] == Surfer::get_id()) {
                 $style = ' class="thread_me"';
             } else {
                 $style = ' class="thread_other"';
             }
             // a clickable label
             $stamp = '#';
             // flag old items on same day
             if (!strncmp($item['edit_date'], gmstrftime('%Y-%m-%d %H:%M:%S', time()), 10)) {
                 $stamp = Skin::build_time($item['edit_date']);
             } else {
                 $stamp = Skin::build_date($item['edit_date']);
             }
             // append this at the end of the comment
             $stamp = ' <div style="float: right; font-size: x-small">' . Skin::build_link(Comments::get_url($item['id']), $stamp, 'basic', i18n::s('Edit')) . '</div>';
             // package everything --change order to get oldest first
             $text = '<dt' . $style . '>' . $author . '</dt><dd' . $style . '>' . $stamp . ucfirst(trim($item['description'])) . '</dd>' . $text;
         }
     }
     // end of processing
     SQL::free($result);
     // finalize the returned definition list
     if ($text) {
         $text = '<dl>' . $text . '</dl>';
     }
     // process yacs codes
     $text = Codes::beautify($text);
     return $text;
 }
Example #10
0
 public function generateCode()
 {
     $data = array();
     $result = 0;
     $count = $_POST['count'];
     for ($i = 0; $i < $count; $i++) {
         $data['activationcode'] = Crypt::encrypt(str_random(20));
         $data['membertype'] = $_POST['membertype'];
         $result = $result + Codes::makeCode($data);
     }
     return $result . " activation codes added.";
 }
Example #11
0
 /**
  * list dates
  *
  * @param resource the SQL result
  * @return string the rendered text
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // build the calendar
     $text = 'BEGIN:VCALENDAR' . CRLF . 'VERSION:2.0' . CRLF . 'PRODID:YACS' . CRLF . 'METHOD:PUBLISH' . CRLF;
     // organization, if any
     if (isset($context['site_name']) && $context['site_name']) {
         $text .= 'X-WR-CALNAME:' . $context['site_name'] . CRLF;
     }
     // process all items in the list
     while ($item = SQL::fetch($result)) {
         // one event at a time
         $text .= 'BEGIN:VEVENT' . CRLF;
         // the event spans limited time
         if (isset($item['duration']) && $item['duration']) {
             $text .= 'DTSTART:' . gmdate('Ymd\\THis\\Z', SQL::strtotime($item['date_stamp'])) . CRLF;
             $text .= 'DTEND:' . gmdate('Ymd\\THis\\Z', SQL::strtotime($item['date_stamp']) + $item['duration'] * 60) . CRLF;
             // a full-day event
         } else {
             $text .= 'DTSTART;VALUE=DATE:' . date('Ymd', SQL::strtotime($item['date_stamp'])) . CRLF;
             $text .= 'DTEND;VALUE=DATE:' . date('Ymd', SQL::strtotime($item['date_stamp']) + 86400) . CRLF;
         }
         // url to view the date
         $text .= 'URL:' . Articles::get_permalink($item) . CRLF;
         // organization, if any
         if (isset($item['introduction']) && $item['introduction']) {
             $text .= 'DESCRIPTION:' . str_replace(array("\n", "\r"), ' ', strip_tags($item['introduction'])) . CRLF;
         }
         // build a valid title
         if (isset($item['title']) && $item['title']) {
             $text .= 'SUMMARY:' . Codes::beautify_title($item['title']) . CRLF;
         }
         // required by Outlook 2003
         if (isset($item['id']) && $item['id']) {
             $text .= 'UID:' . $item['id'] . CRLF;
         }
         // date of creation
         if (isset($item['create_date']) && $item['create_date']) {
             $text .= 'CREATED:' . gmdate('Ymd\\THis\\Z', SQL::strtotime($item['create_date'])) . CRLF;
         }
         // date of last modification
         if (isset($item['edit_date']) && $item['edit_date']) {
             $text .= 'DTSTAMP:' . gmdate('Ymd\\THis\\Z', SQL::strtotime($item['edit_date'])) . CRLF;
         }
         // next event
         $text .= 'SEQUENCE:0' . CRLF . 'END:VEVENT' . CRLF;
     }
     // date of last update
     $text .= 'END:VCALENDAR' . CRLF;
     // end of processing
     SQL::free($result);
     return $text;
 }
Example #12
0
 public function testPrepareCodes()
 {
     $C = new Codes();
     $C->format = "ABC******";
     // 9 characters + ',' will be 10 chars
     $C->prefix = $C->setPrefix($C->format);
     $C->num_random_chars = strlen($C->format) - strlen($C->prefix);
     $C->fieldlength = 100;
     // sets fieldlength artifically low just for test usually 32768
     $num_codes = 101;
     $codes = $C->generateMany($num_codes);
     $code_length = strlen($codes[0]);
     $prep = $C->prepareCodesForInsert($codes);
     $c = ceil($num_codes * ($code_length + 1) / $C->fieldlength);
     //  	 echo "\n | first code : $codes[0] ";
     //  	 echo " | num_codes : $num_codes ";
     //  	 echo " | code_length : $code_length \n";
     print_r($prep);
     // we expect the number of strings of codes to be 11
     $this->assertTrue(count($prep) == $c);
 }
Example #13
0
 public function doPatientCheck(RsPatient $patient, $beginDate = null, $endDate = null, $options = null)
 {
     $data = Codes::lookup($this->getOptionId());
     $type = $this->getListType();
     foreach ($data as $codeType => $codes) {
         foreach ($codes as $code) {
             if (exist_lists_item($patient->id, $type, $codeType . '::' . $code, $endDate)) {
                 return true;
             }
         }
     }
     return false;
 }
Example #14
0
 public function test(CqmPatient $patient, $beginDate, $endDate)
 {
     //Group A Streptococcus Test Array
     $strep_test_code = "'" . implode("','", Codes::lookup(LabResult::STREPTOCOCCUS_TEST, 'LOINC')) . "'";
     //Patients who were tested for Streptococcus A during the same encounter that the antibiotic was prescribed, Encounter category should be office visit.
     $query = "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 po ON po.encounter_id = fe.encounter " . "INNER JOIN procedure_order_code pc ON po.procedure_order_id = pc.procedure_order_id " . "INNER JOIN procedure_report pr on pr.procedure_order_id = po.procedure_order_id " . "INNER JOIN procedure_result pres on pres.procedure_report_id = pr.procedure_report_id " . "WHERE opc.pc_catname = 'Office Visit' AND fe.pid = ? AND (fe.date BETWEEN ? AND  ? ) " . " AND pres.result_code in ({$strep_test_code}) AND ( DATEDIFF(po.date_ordered,fe.date) between 0 and 3 or DATEDIFF(fe.date,po.date_ordered) between 0 and 3)";
     $check = sqlQuery($query, array($patient->id, $beginDate, $endDate));
     if ($check['cnt'] > 0) {
         return true;
     } else {
         return false;
     }
 }
 public function configure()
 {
     $this->widgetSchema['category'] = new sfWidgetFormChoice(array('choices' => Codes::getCategories()));
     $this->validatorSchema['category'] = new sfValidatorChoice(array('required' => false, 'choices' => array_keys(Codes::getCategories())));
     $this->widgetSchema['referenced_relation'] = new sfWidgetFormChoice(array('choices' => array('specimens' => 'Specimen Code', 'specimen_parts' => 'Parts Code')));
     $this->validatorSchema['referenced_relation'] = new sfValidatorChoice(array('required' => false, 'choices' => array('specimens' => 'specimens', 'specimen_parts' => 'specimen_parts')));
     $this->widgetSchema['code_part'] = new sfWidgetFormInput(array(), array('style' => 'width:97%;'));
     $this->widgetSchema['code_from'] = new sfWidgetFormInput(array(), array('class' => 'lsmall_size'));
     $this->widgetSchema['code_to'] = new sfWidgetFormInput(array(), array('class' => 'lsmall_size'));
     $this->validatorSchema['code_part'] = new sfValidatorString(array('required' => false, 'trim' => true));
     $this->validatorSchema['code_from'] = new sfValidatorString(array('required' => false, 'trim' => true));
     $this->validatorSchema['code_to'] = new sfValidatorString(array('required' => false, 'trim' => true));
     $this->mergePostValidator(new CodesLineValidatorSchema());
 }
Example #16
0
 /**
  * list files
  *
  * @param resource the SQL result
  * @return array of resulting items, or NULL
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // we return an array of ($url => $attributes)
     $items = array();
     // empty list
     if (!SQL::count($result)) {
         return $items;
     }
     // sanity check
     if (!isset($this->layout_variant)) {
         $this->layout_variant = 'full';
     }
     // process all items in the list
     while ($item = SQL::fetch($result)) {
         // get the main anchor
         $anchor = Anchors::get($item['anchor']);
         // download the file directly
         $url = Files::get_url($item['id'], 'fetch', $item['file_name']);
         // initialize variables
         $prefix = $suffix = '';
         // flag files that are dead, or created or updated very recently
         if ($item['create_date'] >= $context['fresh']) {
             $suffix .= NEW_FLAG;
         } elseif ($item['edit_date'] >= $context['fresh']) {
             $suffix .= UPDATED_FLAG;
         }
         // signal restricted and private files
         if ($item['active'] == 'N') {
             $prefix .= PRIVATE_FLAG;
         } elseif ($item['active'] == 'R') {
             $prefix .= RESTRICTED_FLAG;
         }
         // file title or file name
         $label = Codes::beautify_title($item['title']);
         if (!$label) {
             $label = ucfirst(str_replace(array('%20', '-', '_'), ' ', $item['file_name']));
         }
         // the main anchor link, except on user profiles
         if (is_object($anchor) && $anchor->get_reference() != $this->focus) {
             $suffix .= ' - <span class="details">' . sprintf(i18n::s('in %s'), Skin::build_link($anchor->get_url(), ucfirst($anchor->get_title()))) . '</span>';
         }
         // list all components for this item
         $items[$url] = array($prefix, $label, $suffix, 'basic', NULL);
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
Example #17
0
 /**
  * list links
  *
  * @param resource the SQL result
  * @return array of resulting items, or NULL
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // we return an array of ($url => $attributes)
     $items = array();
     // empty list
     if (!SQL::count($result)) {
         return $items;
     }
     // process all items in the list
     while ($item = SQL::fetch($result)) {
         // get the anchor for this link
         if ($item['anchor']) {
             $anchor = Anchors::get($item['anchor']);
         }
         // url is the link itself
         $url = $item['link_url'];
         // time of last update
         $time = SQL::strtotime($item['edit_date']);
         // the title as the label
         if ($item['title']) {
             $label = $item['title'];
         } else {
             $label = $url;
         }
         // the section
         $section = '';
         if (is_object($anchor)) {
             $section = ucfirst($anchor->get_title());
         }
         // the author(s) is an e-mail address, according to rss 2.0 spec
         $author = $item['edit_address'] . ' (' . $item['edit_name'] . ')';
         // the description
         $description = Codes::beautify($item['description']);
         // cap the number of words
         $description = Skin::cap($description, 300);
         // fix image references
         $description = preg_replace('#"/([^">]+?)"#', '"' . $context['url_to_home'] . '/$1"', $description);
         $introduction = $description;
         // other rss fields
         $extensions = array();
         // list all components for this item
         $items[$url] = array($time, $label, $author, $section, NULL, $introduction, $description, $extensions);
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
Example #18
0
 /**
  * list dates
  *
  * @param resource the SQL result
  * @return string the rendered text
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // we return an array of ($url => $attributes)
     $items = array();
     // empty list
     if (!SQL::count($result)) {
         return $items;
     }
     // process all items in the list
     while ($item = SQL::fetch($result)) {
         // the url to use
         $url = Articles::get_permalink($item);
         // initialize variables
         $prefix = $suffix = $icon = '';
         // signal restricted and private dates/articles
         if (!isset($item['publish_date']) || $item['publish_date'] <= NULL_DATE) {
             $prefix .= DRAFT_FLAG;
         }
         // signal restricted and private dates/articles
         if (!isset($item['active'])) {
         } elseif ($item['active'] == 'N') {
             $prefix .= PRIVATE_FLAG;
         } elseif ($item['active'] == 'R') {
             $prefix .= RESTRICTED_FLAG;
         }
         // flag new dates/articles
         if ($item['edit_date'] >= $context['fresh']) {
             $suffix .= NEW_FLAG;
         }
         // build a valid label
         if (isset($item['title'])) {
             $label = Codes::beautify_title($item['title']);
             if (isset($item['date_stamp'])) {
                 $label .= ' [' . Skin::build_date($item['date_stamp'], 'day') . ']';
             }
         } else {
             $label = Skin::build_date($item['date_stamp'], 'day');
         }
         // may have variant overlay for links
         $link_type = $this->has_variant('overlaid') ? 'overlaid' : 'basic';
         // list all components for this item
         $items[$url] = array($prefix, $label, $suffix, $link_type, NULL, $item['date_stamp']);
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
Example #19
0
 public function test(CqmPatient $patient, $beginDate, $endDate)
 {
     //Also exclude patients with a diagnosis of pregnancy during the measurement period.
     if (Helper::check(ClinicalType::DIAGNOSIS, Diagnosis::PREGNANCY, $patient, $beginDate, $beginDate) || Helper::check(ClinicalType::DIAGNOSIS, Diagnosis::END_STAGE_RENAL_DISEASE, $patient, $beginDate, $beginDate) || Helper::check(ClinicalType::DIAGNOSIS, Diagnosis::CHRONIC_KIDNEY_DISEASE, $patient, $beginDate, $beginDate)) {
         return true;
     }
     $procedure_code = implode(',', Codes::lookup(Procedure::DIALYSIS_SERVICE, 'SNOMED'));
     //Dialysis procedure exists exclude the patient
     $sql = "SELECT count(*) as cnt FROM procedure_order pr " . "INNER JOIN procedure_order_code prc ON pr.procedure_order_id = prc.procedure_order_id " . "WHERE pr.patient_id = ? " . "AND prc.procedure_code IN ({$procedure_code}) " . "AND (pr.date_ordered BETWEEN ? AND ?)";
     //echo $sql;
     $check = sqlQuery($sql, array($patient->id, $beginDate, $endDate));
     if ($check['cnt'] > 0) {
         return true;
     }
     return false;
 }
Example #20
0
 public function render($matches)
 {
     $text = '';
     $mode = $matches[0];
     if ($mode == 'menu') {
         $variant = 'menu_1';
     } elseif ($mode = 'submenu') {
         $variant = 'menu_2';
     } else {
         $variant = $mode;
     }
     $url = isset($matches[2]) ? encode_link($matches[2]) : encode_link($matches[1]);
     $label = isset($matches[2]) ? Codes::fix_tags($matches[1]) : $matches[1];
     $text = Skin::build_link($url, $label, $variant);
     return $text;
 }
Example #21
0
 public function test(CqmPatient $patient, $beginDate, $endDate)
 {
     $vac_medication = implode(',', Codes::lookup(Medication::PNEUMOCOCCAL_VAC, 'CVX'));
     $vac_procedure = implode(',', Codes::lookup(Procedure::PNEUMOCOCCAL_VACCINE, 'SNOMED'));
     $query = "select count(*) cnt from form_encounter fe " . "INNER JOIN procedure_order po on po.patient_id = fe.pid " . "INNER JOIN procedure_order_code poc on poc.procedure_order_id = po.procedure_order_id " . "WHERE fe.pid = ? AND fe.date between ? and ? " . "AND poc.procedure_code in ({$vac_procedure}) AND po.date_ordered between ? and ? ";
     $sql = sqlQuery($query, array($patient->id, $beginDate, $endDate, $beginDate, $endDate));
     if ($sql['cnt'] > 0) {
         return true;
     }
     $query = "select count(*) cnt from form_encounter fe " . "INNER JOIN immunizations imm on imm.patient_id = fe.pid " . "WHERE fe.pid = ? and fe.date between ? and  ? " . "AND imm.cvx_code in ({$vac_medication}) AND imm.administered_date between ? and ?";
     $sql = sqlQuery($query, array($patient->id, $beginDate, $endDate, $beginDate, $endDate));
     if ($sql['cnt'] > 0) {
         return true;
     }
     return false;
 }
Example #22
0
 /**
  * check access rights
  *
  * @param string script name
  * @paral string target anchor, if any
  * @return boolean FALSE if access is denied, TRUE otherwise
  */
 function allow($script, $anchor = NULL)
 {
     global $context;
     // limit the scope of our check
     if ($script != 'files/view.php' && $script != 'files/fetch.php' && $script != 'files/fetch_all.php' && $script != 'files/stream.php') {
         return TRUE;
     }
     // sanity check
     if (!$anchor) {
         die(i18n::s('No anchor has been found.'));
     }
     // stop here if the agreement has been gathered previously
     if (isset($_SESSION['agreements']) && is_array($agreements = $_SESSION['agreements'])) {
         foreach ($agreements as $agreement) {
             if ($agreement == $anchor) {
                 return TRUE;
             }
         }
     }
     // which agreement?
     if (!$this->parameters) {
         die(sprintf(i18n::s('No parameter has been provided to %s'), 'behaviors/agree_on_file_access'));
     }
     // do we have a related file to display?
     if (!is_readable($context['path_to_root'] . 'behaviors/agreements/' . $this->parameters)) {
         die(sprintf(i18n::s('Bad parameter to behavior <code>%s %s</code>'), 'agree_on_file_access', $this->parameters));
     }
     // splash message
     $context['text'] .= '<p class="agreement">' . i18n::s('Before moving forward, please read following text and express yourself at the end of the page.') . '</p><hr/>' . "\n";
     // load and display the file to be displayed
     $context['text'] .= Codes::beautify(Safe::file_get_contents($context['path_to_root'] . 'behaviors/agreements/' . $this->parameters));
     // target link to record agreement
     if ($context['with_friendly_urls'] == 'Y') {
         $agree_link = 'behaviors/agreements/agree.php/' . rawurlencode($anchor);
     } else {
         $agree_link = 'behaviors/agreements/agree.php?id=' . urlencode($anchor);
     }
     // display confirmation buttons at the end of the agreement
     $context['text'] .= '<hr/><p class="agreement">' . i18n::s('Do you agree?');
     $context['text'] .= ' ' . Skin::build_link($agree_link, i18n::s('Yes'), 'button');
     $context['text'] .= ' ' . Skin::build_link('behaviors/agreements/deny.php', i18n::s('No'), 'button') . '</p>' . "\n";
     // render the skin based only on text provided by this behavior
     render_skin();
     exit;
 }
 public function test(CqmPatient $patient, $beginDate, $endDate)
 {
     $age = $patient->calculateAgeOnDate($beginDate);
     if ($age >= 18 && $age < 75 && Helper::check(ClinicalType::ENCOUNTER, Encounter::ENC_OFF_VIS, $patient, $beginDate, $endDate)) {
         $diabetes_codes = array();
         foreach (Codes::lookup(Diagnosis::DIABETES, 'SNOMED-CT') as $code) {
             $diabetes_codes[] = "SNOMED-CT:" . $code;
         }
         $diabetes_codes = "'" . implode("','", $diabetes_codes) . "'";
         $query = "select count(*) cnt from form_encounter fe " . "inner join lists l on ( l.type='medical_problem' and l.pid = fe.pid )" . "where fe.pid = ? and fe.date between ? and ? " . "and l.diagnosis in ({$diabetes_codes}) and (l.begdate < ? or (l.begdate between ? and ? )) and (l.enddate is null or l.enddate > ? )";
         $sql = sqlQuery($query, array($patient->id, $beginDate, $endDate, $beginDate, $beginDate, $endDate, $endDate));
         if ($sql['cnt'] > 0) {
             return true;
         }
         return false;
     }
     return false;
 }
Example #24
0
 /**
  * list users
  *
  * @param resource the SQL result
  * @return string the rendered text
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // empty list
     if (!SQL::count($result)) {
         $output = array();
         return $output;
     }
     // we return an array of ($url => $attributes)
     $items = array();
     // process all items in the list
     while ($item = SQL::fetch($result)) {
         // url to view the user profile
         $url = Users::get_permalink($item);
         // time of last update
         $time = SQL::strtotime($item['edit_date']);
         // item title
         if ($item['full_name']) {
             $label = ucfirst(Skin::strip($item['full_name'], 10));
         } else {
             $label = ucfirst(Skin::strip($item['nick_name'], 10));
         }
         // the section
         $section = '';
         // the author(s) is an e-mail address, according to rss 2.0 spec
         $author .= $item['edit_address'] . ' (' . $item['edit_name'] . ')';
         // introduction
         $introduction = Codes::beautify($item['introduction']);
         // the description
         $description = Codes::beautify($item['description']);
         // cap the number of words
         $description = Skin::cap($description, 300);
         // fix image references
         $description = preg_replace('#"/([^">]+?)"#', '"' . $context['url_to_home'] . '/$1"', $description);
         // other rss fields
         $extensions = array();
         // list all components for this item
         $items[$url] = array($time, $label, $author, $section, $icon, $introduction, $description, $extensions);
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
Example #25
0
 /**
  * list files
  *
  * @param resource the SQL result
  * @return array of resulting items, or NULL
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // we return an array of ($url => $attributes)
     $items = array();
     // empty list
     if (!SQL::count($result)) {
         return $items;
     }
     // process all items in the list
     while ($item = SQL::fetch($result)) {
         // download the file directly
         $url = Files::get_url($item['id'], 'fetch', $item['file_name']);
         // initialize variables
         $prefix = $suffix = '';
         // flag files that are dead, or created or updated very recently
         if ($item['create_date'] >= $context['fresh']) {
             $suffix .= NEW_FLAG;
         } elseif ($item['edit_date'] >= $context['fresh']) {
             $suffix .= UPDATED_FLAG;
         }
         // signal restricted and private files
         if ($item['active'] == 'N') {
             $prefix .= PRIVATE_FLAG;
         } elseif ($item['active'] == 'R') {
             $prefix .= RESTRICTED_FLAG;
         }
         // file title or file name
         $label = Codes::beautify_title($item['title']);
         if (!$label) {
             $label = ucfirst(str_replace(array('%20', '-', '_'), ' ', $item['file_name']));
         }
         // with hits
         if ($item['hits'] > 1) {
             $suffix .= ' <span class="details">- ' . Skin::build_number($item['hits'], i18n::s('downloads')) . '</span>';
         }
         // list all components for this item
         $items[$url] = array($prefix, $label, $suffix, 'basic', NULL);
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
Example #26
0
 public function test(CqmPatient $patient, $beginDate, $endDate)
 {
     $periodPlus89Days = date('Y-m-d 00:00:00', strtotime('+89 day', strtotime($beginDate)));
     $periodMinus153Days = date('Y-m-d 00:00:00', strtotime('-153 day', strtotime($beginDate)));
     $influenza_procedure = implode(',', Codes::lookup(Procedure::INFLU_VACCINE, 'SNOMED'));
     $influenza_medication = implode(',', Codes::lookup(Medication::INFLUENZA_VACCINE, 'CVX'));
     $provider_communication = implode(',', Codes::lookup(Communication::PREV_RECEIPT_VACCINE, 'SNOMED'));
     // Influenza vaccine procedure check
     $query = "select count(*) as cnt from form_encounter fe " . "INNER JOIN procedure_order po on po.patient_id = fe.pid " . "INNER JOIN procedure_order_code poc on po.procedure_order_id = poc.procedure_order_id " . "WHERE pid = ? and fe.date between ? and  ? " . "AND poc.procedure_code in ({$influenza_procedure}) and ( po.date_ordered <= ? or po.date_ordered <= ? )";
     $sql = sqlQuery($query, array($patient->id, $beginDate, $endDate, $periodMinus153Days, $periodPlus89Days));
     if ($sql['cnt'] > 0) {
         return true;
     }
     $query = "select count(*) as cnt from form_encounter fe " . "INNER JOIN immunizations imm on imm.patient_id = fe.pid " . "WHERE pid = ? and fe.date between ? and ? " . "AND imm.cvx_code in ({$influenza_medication}) and (imm.administered_date <= ? or imm.administered_date <= ?) ";
     $sql = sqlQuery($query, array($patient->id, $beginDate, $endDate, $periodMinus153Days, $periodPlus89Days));
     if ($sql['cnt'] > 0) {
         return true;
     }
     return false;
 }
 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
         $antibiotics = implode(',', Codes::lookup(Medication::ANTIBIOTIC_FOR_PHARYNGITIS, 'RXNORM'));
         $query = "SELECT p.drug as drug FROM form_encounter fe " . "INNER JOIN openemr_postcalendar_categories opc ON fe.pc_catid = opc.pc_catid " . "INNER JOIN prescriptions p ON fe.pid = p.patient_id " . "WHERE opc.pc_catname = 'Office Visit' AND fe.pid = ? AND (fe.date BETWEEN ? AND ? ) " . " AND p.rxnorm_drugcode in ( {$antibiotics} ) AND DATEDIFF(fe.date,p.date_added) <= 3";
         $check = sqlQuery($query, array($patient->id, $beginDate, $endDate));
         if ($check['drug'] != "") {
             if (Helper::check(ClinicalType::DIAGNOSIS, Diagnosis::ACUTE_PHARYNGITIS, $patient, $beginDate, $endDate) || Helper::check(ClinicalType::DIAGNOSIS, Diagnosis::ACUTE_TONSILLITIS, $patient, $beginDate, $endDate)) {
                 return true;
             } else {
                 return false;
             }
         } else {
             return false;
         }
     }
     return false;
 }
Example #28
0
 /**
  * list files
  *
  * @param resource the SQL result
  * @return array of resulting items, or NULL
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // we return an array of ($url => $attributes)
     $items = array();
     // empty list
     if (!SQL::count($result)) {
         return $items;
     }
     // process all items in the list
     while ($item = SQL::fetch($result)) {
         // download the file directly
         $url = Files::get_url($item['id'], 'fetch', $item['file_name']);
         // file title or file name
         $label = Codes::beautify_title($item['title']);
         if (!$label) {
             $label = ucfirst(str_replace(array('%20', '-', '_'), ' ', $item['file_name']));
         }
         // initialize variables
         $prefix = $suffix = '';
         $contributor = Users::get_link($item['create_name'], $item['create_address'], $item['create_id']);
         $flag = '';
         if ($item['create_date'] >= $context['fresh']) {
             $flag = NEW_FLAG;
         } elseif ($item['edit_date'] >= $context['fresh']) {
             $flag = UPDATED_FLAG;
         }
         $suffix .= '<span class="details"> - ' . sprintf(i18n::s('By %s'), $contributor) . ' ' . Skin::build_date($item['create_date']) . $flag . '</span>';
         // signal restricted and private files
         if ($item['active'] == 'N' && defined('PRIVATE_FLAG')) {
             $prefix .= PRIVATE_FLAG;
         } elseif ($item['active'] == 'R' && defined('RESTRICTED_FLAG')) {
             $prefix .= RESTRICTED_FLAG;
         }
         // list all components for this item
         $items[$url] = array($prefix, $label, $suffix, 'file', NULL);
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
 public function configure()
 {
     $this->useFields(array('code_category', 'code_prefix', 'code_prefix_separator', 'code', 'code_suffix', 'code_suffix_separator'));
     $this->widgetSchema['code_category'] = new sfWidgetFormChoice(array('choices' => Codes::getCategories()));
     $this->validatorSchema['code_category'] = new sfValidatorChoice(array('required' => false, 'choices' => array_keys(Codes::getCategories())));
     $this->widgetSchema['code_prefix'] = new sfWidgetFormInput();
     $this->widgetSchema['code_prefix']->setAttributes(array('class' => 'lsmall_size'));
     $this->validatorSchema['code_prefix'] = new sfValidatorString(array('required' => false, 'trim' => true));
     $this->widgetSchema['code_prefix_separator'] = new widgetFormSelectComplete(array('model' => 'Codes', 'table_method' => 'getDistinctPrefixSep', 'method' => 'getCodePrefixSeparator', 'key_method' => 'getCodePrefixSeparator', 'add_empty' => true, 'change_label' => '', 'add_label' => ''));
     $this->widgetSchema['code_prefix_separator']->setAttributes(array('class' => 'vvsmall_size'));
     $this->widgetSchema['code'] = new sfWidgetFormInput();
     //mrac 2015 06 03 new css class 'mrac_input_mask' for input mask
     $this->widgetSchema['code']->setAttributes(array('class' => 'medium_small_size code_mrac_input_mask'));
     $this->validatorSchema['code'] = new sfValidatorString(array('required' => false, 'trim' => true));
     $this->widgetSchema['code_suffix'] = new sfWidgetFormInput();
     $this->widgetSchema['code_suffix']->setAttributes(array('class' => 'lsmall_size'));
     $this->validatorSchema['code_suffix'] = new sfValidatorString(array('required' => false, 'trim' => true));
     $this->widgetSchema['code_suffix_separator'] = new widgetFormSelectComplete(array('model' => 'Codes', 'table_method' => 'getDistinctSuffixSep', 'method' => 'getCodeSuffixSeparator', 'key_method' => 'getCodeSuffixSeparator', 'add_empty' => true, 'change_label' => '', 'add_label' => ''));
     $this->widgetSchema['code_suffix_separator']->setAttributes(array('class' => 'vvsmall_size'));
     $this->mergePostValidator(new CodesValidatorSchema());
 }
Example #30
0
 public function test(CqmPatient $patient, $beginDate, $endDate)
 {
     //Children who are taking antibiotics in the 30 days prior to the diagnosis of pharyngitis
     $antibiotics = implode(',', Codes::lookup(Medication::ANTIBIOTIC_FOR_PHARYNGITIS, 'RXNORM'));
     $pharyngitis_snomed_codes = $pharyngitis_icd9_codes = $pharyngitis_icd10_codes = array();
     foreach (Codes::lookup(Diagnosis::ACUTE_PHARYNGITIS, 'SNOMED-CT') as $code) {
         $pharyngitis_snomed_codes[] = "SNOMED-CT:" . $code;
     }
     foreach (Codes::lookup(Diagnosis::ACUTE_PHARYNGITIS, 'ICD9') as $code) {
         $pharyngitis_icd9_codes[] = "ICD9:" . $code;
     }
     foreach (Codes::lookup(Diagnosis::ACUTE_PHARYNGITIS, 'ICD10') as $code) {
         $pharyngitis_icd10_codes[] = "ICD10:" . $code;
     }
     $pharyngitis_snomed_codes = "'" . implode("','", $pharyngitis_snomed_codes) . "'";
     $pharyngitis_icd9_codes = "'" . implode("','", $pharyngitis_icd9_codes) . "'";
     $pharyngitis_icd10_codes = "'" . implode("','", $pharyngitis_icd10_codes) . "'";
     $tonsillitis_snomed_codes = $tonsillitis_icd9_codes = $tonsillitis_icd10_codes = array();
     foreach (Codes::lookup(Diagnosis::ACUTE_TONSILLITIS, 'SNOMED-CT') as $code) {
         $tonsillitis_snomed_codes[] = "SNOMED-CT:" . $code;
     }
     foreach (Codes::lookup(Diagnosis::ACUTE_TONSILLITIS, 'ICD9') as $code) {
         $tonsillitis_icd9_codes[] = "ICD9:" . $code;
     }
     foreach (Codes::lookup(Diagnosis::ACUTE_TONSILLITIS, 'ICD10') as $code) {
         $tonsillitis_icd10_codes[] = "ICD10:" . $code;
     }
     $tonsillitis_snomed_codes = "'" . implode("','", $tonsillitis_snomed_codes) . "'";
     $tonsillitis_icd9_codes = "'" . implode("','", $tonsillitis_icd9_codes) . "'";
     $tonsillitis_icd10_codes = "'" . implode(',', $tonsillitis_icd10_codes) . "'";
     $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='medical_problem' and fe.pid = l.pid " . "INNER JOIN prescriptions p ON fe.pid = p.patient_id " . "WHERE opc.pc_catname = 'Office Visit' AND fe.pid = ? AND fe.date BETWEEN ? and ? " . " AND p.rxnorm_drugcode in ( {$antibiotics} )" . " AND (l.diagnosis in ({$pharyngitis_snomed_codes}) or l.diagnosis in ({$pharyngitis_icd9_codes}) or l.diagnosis in({$pharyngitis_icd10_codes}) " . " or l.diagnosis in({$tonsillitis_snomed_codes}) or l.diagnosis in ({$tonsillitis_icd9_codes}) or l.diagnosis in ({$tonsillitis_icd10_codes})) " . " AND DATEDIFF(l.date,p.date_added) between 0 and 30 AND p.active = 1";
     $check = sqlQuery($query, array($patient->id, $beginDate, $endDate));
     if ($check['cnt'] >= 1) {
         //more than one medication it will exclude
         return true;
     } else {
         return false;
     }
 }