/**
  * Get an array of all concept classes formatted for an HTML select dropdown.
  * This method automatically combines datatypes of the same name across dictionaries
  * into a single select box.
  * @return array
  */
 public function getHtmlChecklistArray(ConceptDatatypeCollection $coll_selected = null)
 {
     /**
      * $arr_display has 3 fields: value, display, source. Source is another array of 
      * dictionary sources in which the object is present.
      */
     $arr_display = array();
     // Combine
     foreach ($this->getKeys() as $key) {
         $o = $this->Get($key);
         if (!isset($arr_display[strtolower($o->name)])) {
             $arr_display[strtolower($o->name)] = array('value' => strtolower($o->name), 'display' => $o->name, 'hint' => '', 'selected' => false, 'source' => array());
         }
         if ($arr_display[strtolower($o->name)]['selected'] === false && $coll_selected->IsMember($key)) {
             $arr_display[strtolower($o->name)]['selected'] = true;
         }
         $arr_display[strtolower($o->name)]['source'][] = $o->getSourceDictionary()->dict_db;
     }
     // Set hint column to indicate the list of dictionaries
     foreach (array_keys($arr_display) as $key) {
         $hint = '';
         foreach ($arr_display[$key]['source'] as $source_text) {
             if ($hint) {
                 $hint .= ', ';
             }
             $hint .= $source_text;
         }
         if ($hint) {
             $hint = '"' . $arr_display[$key]['display'] . '" is in the following dictionaries: ' . $hint;
         }
         $arr_display[$key]['hint'] = $hint;
     }
     return $arr_display;
 }
 /**
  * Loads the concept datatypes from the specified dictionary.
  * @return ConceptDatatypeCollection 
  */
 public function loadConceptDatatypes(ConceptSearchSource $css_dict)
 {
     // get the data
     $sql_datatypes = 'select concept_datatype_id, name, description, hl7_abbreviation, uuid ' . 'from concept_datatype ' . 'where retired != 1 ' . 'order by name';
     if ($this->debug) {
         echo '<p><b>Loading concept datatypes for ' . $css_dict->dict_db . ':</b><br> ' . $sql_datatypes . '</p>';
     }
     $rsc_datatypes = mysql_query($sql_datatypes, $css_dict->getConnection());
     if (!$rsc_datatypes) {
         echo "Could not query db in ConceptSearchFactory::_loadConceptDatatypes: " . mysql_error();
     }
     // Create the datatype collection
     $cdc = new ConceptDatatypeCollection();
     while ($row = mysql_fetch_assoc($rsc_datatypes)) {
         $cd = new ConceptDatatype($row['concept_datatype_id'], $row['name'], $row['description'], $row['hl7_abbreviation'], $row['uuid']);
         $cd->setSourceDictionary($css_dict);
         // $key = '<database_name>:datatype(<concept_datatype_id>)
         $key = $css_dict->dict_db . ':datatype(' . $row['concept_datatype_id'] . ')';
         $cdc->Add($key, $cd);
     }
     return $cdc;
 }