Class: Qa::MeshTree

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/qa/mesh_tree.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.classify_all_treesObject



4
5
6
# File 'app/models/qa/mesh_tree.rb', line 4

def self.classify_all_trees
  MeshTreeStructure.find_each(&:classify_tree!)
end

Instance Method Details

#classify_treeObject



17
18
19
20
# File 'app/models/qa/mesh_tree.rb', line 17

def classify_tree
  tree_levels = initial_segements_of(tree_structure)
  tree_levels.map(&:lookup_tree_term)
end

#classify_tree!Object



22
23
24
25
26
27
28
# File 'app/models/qa/mesh_tree.rb', line 22

def classify_tree!
  unless classify_tree.empty?
    tree_path = classify_tree.join('|')
    puts "After Join #{tree_path.inspect}"
    update_attribute(:eval_tree_path, tree_path)
  end
end

#eval_tree_pathObject



8
9
10
11
12
13
14
15
# File 'app/models/qa/mesh_tree.rb', line 8

def eval_tree_path
  trees = read_attribute(:eval_tree_path) || write_attribute(:eval_tree_path, "")
  if trees
    trees.split("|")
  else
    []
  end
end

#lookup_tree_term(tree_id) ⇒ Object

given a tree id, return the main subject term e.g. ‘C03.752.530’ returns ‘Malaria’



32
33
34
# File 'app/models/qa/mesh_tree.rb', line 32

def lookup_tree_term(tree_id)
  self.class.get_term(tree_id).first.term
end