Exemplo n.º 1
0
 /**
  * True if this search term object matches the passed Concept; false otherwise.
  * @param Concept $c
  * @param mixed $search_term_type One of the MCL_SEARCH_TERM_TYPE_* constants. Use to force a specific type of comparison
  * @return bool
  */
 public function isMatch(Concept $c, $search_term_type = null)
 {
     // Prepare the search term type for comparison
     if (is_null($search_term_type)) {
         $search_term_type = $this->term_type;
     }
     // Now do the comparison
     if ($search_term_type == MCL_SEARCH_TERM_TYPE_ALL) {
         return true;
     } elseif ($search_term_type == MCL_SEARCH_TERM_TYPE_CONCEPT_ID) {
         if ($this->needle == $c->concept_id) {
             return true;
         }
     } elseif ($search_term_type == MCL_SEARCH_TERM_TYPE_CONCEPT_ID_RANGE) {
         list($min, $max) = explode('-', $this->needle);
         if ($c->concept_id >= $min && $c->concept_id <= $max) {
             return true;
         }
     } elseif ($search_term_type == MCL_SEARCH_TERM_TYPE_MAP_CODE) {
         foreach ($c->getConceptMappingIds() as $mapcode_id) {
             $subject = $c->getConceptMapping($mapcode_id)->source_code;
             if (preg_match('/\\b' . addslashes($this->needle) . '/i', $subject)) {
                 return true;
             }
         }
     } elseif ($search_term_type == MCL_SEARCH_TERM_TYPE_MAP_CODE_RANGE) {
         // TODO: MCL_SEARCH_TERM_TYPE_MAP_CODE_RANGE
     } elseif ($search_term_type == MCL_SEARCH_TERM_TYPE_TEXT) {
         foreach ($c->getConceptNameIds() as $name_id) {
             $subject = $c->getConceptName($name_id)->name;
             if (preg_match('/\\b' . addslashes($this->needle) . '/i', $subject)) {
                 return true;
             }
         }
         foreach ($c->getConceptDescriptionIds() as $desc_id) {
             $subject = $c->getConceptDescription($desc_id)->description;
             if (preg_match('/\\b' . addslashes($this->needle) . '/i', $subject)) {
                 return true;
             }
         }
     } elseif ($search_term_type == MCL_SEARCH_TERM_TYPE_CONCEPT_NAME) {
         foreach ($c->getConceptNameIds() as $name_id) {
             $subject = $c->getConceptName($name_id)->name;
             if (preg_match('/\\b' . addslashes($this->needle) . '/i', $subject)) {
                 return true;
             }
         }
     } elseif ($search_term_type == MCL_SEARCH_TERM_TYPE_CONCEPT_DESCRIPTION) {
         foreach ($c->getConceptDescriptionIds() as $desc_id) {
             $subject = $c->getConceptDescription($desc_id)->description;
             if (preg_match('/\\b' . addslashes($this->needle) . '/i', $subject)) {
                 return true;
             }
         }
     } elseif ($search_term_type == MCL_SEARCH_TERM_TYPE_UUID) {
         if (strtolower($this->needle) == strtolower(substr($c->uuid, 0, strlen($this->needle)))) {
             return true;
         }
     } elseif ($search_term_type == MCL_SEARCH_TERM_TYPE_LIST) {
         // TODO: MCL_SEARCH_TERM_TYPE_LIST
     } elseif ($search_term_type == MCL_SEARCH_TERM_TYPE_MAP_SOURCE) {
         // TODO: MCL_SEARCH_TERM_TYPE_MAP_SOURCE
     }
     return false;
 }
 /**
  * Render the mappings column
  */
 protected function _renderColumn_Mappings(ConceptSearchResultsGroup $csrg, Concept $c, $group_i, $concept_i)
 {
     echo "\n<td class=\"col_4\">\n\t";
     echo '<div class="content">';
     // Get the search terms
     $arr_term_type = array(MCL_SEARCH_TERM_TYPE_MAP_CODE);
     $arr_search_term = $csrg->csg->getSearchTermCollection()->getSearchTerms($arr_term_type, null, true);
     // Concept Mappings
     echo "<div style=\"margin-bottom:6px;\">";
     foreach ($c->getConceptMappingIds() as $_mapping_i) {
         // Setup display of mapping
         $url_mapcode = '';
         $target = '';
         $cm = $c->getConceptMapping($_mapping_i);
         $url_mapsource = 'search.php?q=' . urlencode("source:'" . $cm->source_name . "'") . '&source=' . urlencode($c->css_dict->dict_db);
         // SNOMED
         if ($cm->source_name == 'SNOMED CT' || $cm->source_name == 'SNOMED NP') {
             $url_mapcode = 'http://nciterms.nci.nih.gov/ncitbrowser/ConceptReport.jsp?dictionary=' . 'SNOMED%20Clinical%20Terms' . '&amp;type=all' . '&amp;code=' . urlencode($cm->source_code);
             $target = '_blank';
         } elseif (substr($cm->source_name, 0, 10) == 'ICD-10-WHO') {
             //$url_mapcode = 'http://www.icd10data.com/Search.aspx?codebook=AllCodes&search=' . urlencode($cm->source_code);
             $url_mapcode = 'http://apps.who.int/classifications/icd10/browse/2010/en#/' . urlencode($cm->source_code);
             $target = '_blank';
         } elseif ($cm->source_name == 'PIH') {
             $url_mapcode = $this->getSearchUrl('id:' . $cm->source_code, array('source' => 'pih_concept_dict'));
         } elseif ($cm->source_name == 'AMPATH') {
             $url_mapcode = $this->getSearchUrl('id:' . $cm->source_code, array('source' => 'ampath_concept_dict'));
         } elseif ($cm->source_name == 'LOINC') {
             $url_mapcode = 'http://search.loinc.org/LOINC/regular/' . trim($cm->source_code) . '.html';
             $target = '_blank';
         }
         // Display the mapping
         echo '<strong><a href="' . $url_mapsource . '">' . htmlentities($cm->source_name) . '</a></strong>: ';
         // Display the source code
         if ($url_mapcode) {
             echo '<a href="' . $url_mapcode . '"';
             if ($target) {
                 echo ' target="' . $target . '"';
             }
             echo '>';
         }
         $source_code = htmlentities($cm->source_code);
         foreach ($arr_search_term as $search_term) {
             $source_code = preg_replace('/\\b(' . addslashes($search_term->needle) . ')/i', '<span class="h">$1</span>', $source_code);
         }
         echo $source_code;
         if ($url_mapcode) {
             echo '</a>';
         }
         echo "<br />";
     }
     echo "</div>";
     // Concept lists
     if ($c->hasConceptLists()) {
         echo "<div style=\"margin-bottom:6px;\">Member of: ";
         $i = 0;
         foreach ($c->getConceptListIds() as $_concept_list_id) {
             if ($i) {
                 echo ', ';
             }
             //$_list_name = $this->cc->getConceptListName($_concept_list_id);
             if ($css_list = $this->csr->cs->getAllSources()->getConceptList($_concept_list_id)) {
                 $_list_name = $css_list->list_name;
             } else {
                 $_list_name = $_concept_list_id;
             }
             $_url = "search.php?q=" . urlencode("list:'" . $_list_name . "'");
             echo '<a href="' . $_url . '">' . htmlentities($_list_name) . '</a>';
             $i++;
         }
         echo "</div>";
     }
     echo "</div>\n";
     echo "\n</td>\n";
 }