Beispiel #1
0
 /**
  * Get the HL7v2 mapping table values
  *
  * @param string  $table           The table to get
  * @param boolean $from_mb         Get the reversed table (MB => HL7)
  * @param bool    $get_description Return the escriptions instead of the value
  *
  * @return array The table
  */
 static function getTable($table, $from_mb = true, $get_description = false)
 {
     if (self::$ds === null) {
         return;
     }
     if (self::$ds === false) {
         self::$ds = CSQLDataSource::get("hl7v2");
     }
     static $tables = array();
     if (isset($tables[$table][$from_mb])) {
         return $tables[$table][$from_mb];
     }
     $where = array("number" => self::$ds->prepare("=%", $table));
     if ($from_mb) {
         $cols = array("code_mb_from", $get_description ? "description" : "code_hl7_to");
     } else {
         $cols = array("code_hl7_from", $get_description ? "description" : "code_mb_to");
     }
     $req = new CRequest();
     $req->addSelect($cols);
     $req->addTable("table_entry");
     $req->addWhere($where);
     $result = self::$ds->loadHashList($req->makeSelect());
     if (!$get_description) {
         $tables[$table][$from_mb] = $result;
     }
     return $result;
 }