Class: ConceptQL::FakeAnnotater
- Inherits:
-
Object
- Object
- ConceptQL::FakeAnnotater
- Defined in:
- lib/conceptql/fake_annotater.rb
Constant Summary collapse
- DOMAINS =
{ # Conditions condition: :condition_occurrence, primary_diagnosis: :condition_occurrence, icd9: :condition_occurrence, icd10: :condition_occurrence, condition_type: :condition_occurrence, medcode: :condition_occurrence, # Procedures procedure: :procedure_occurrence, cpt: :procedure_occurrence, drg: :procedure_occurrence, hcpcs: :procedure_occurrence, icd9_procedure: :procedure_occurrence, medcode_procedure: :procedure_occurrence, # Procedure Cost procedure_cost: :procedure_cost, # Visits visit_occurrence: :visit_occurrence, place_of_service_code: :visit_occurrence, # Person person: :person, gender: :person, race: :person, # Payer payer: :payer_plan_period, # Death death: :death, # Observation loinc: :observation, from_seer_visits: :observation, to_seer_visits: :observation, # Drug drug_exposure: :drug_exposure, rxnorm: :drug_exposure, drug_cost: :drug_cost, drug_type_concept_id: :drug_exposure, drug_type_concept: :drug_exposure, prodcode: :drug_exposure, # Date Operators date_range: :date, # Miscelaneous operators concept: :misc, vsac: :misc, numeric: :person, algorithm: :misc, }
Instance Attribute Summary collapse
-
#statement ⇒ Object
readonly
Returns the value of attribute statement.
Instance Method Summary collapse
- #annotate ⇒ Object
- #fetch_domains(label) ⇒ Object
-
#initialize(statement) ⇒ FakeAnnotater
constructor
A new instance of FakeAnnotater.
- #previous_domains(arr) ⇒ Object
- #recorded_domains ⇒ Object
- #save_domains(op) ⇒ Object
- #traverse(stmt) ⇒ Object
Constructor Details
#initialize(statement) ⇒ FakeAnnotater
Returns a new instance of FakeAnnotater.
66 67 68 |
# File 'lib/conceptql/fake_annotater.rb', line 66 def initialize(statement) @statement = statement end |
Instance Attribute Details
#statement ⇒ Object (readonly)
Returns the value of attribute statement.
6 7 8 |
# File 'lib/conceptql/fake_annotater.rb', line 6 def statement @statement end |
Instance Method Details
#annotate ⇒ Object
70 71 72 |
# File 'lib/conceptql/fake_annotater.rb', line 70 def annotate traverse(statement) end |
#fetch_domains(label) ⇒ Object
115 116 117 |
# File 'lib/conceptql/fake_annotater.rb', line 115 def fetch_domains(label) recorded_domains[label] end |
#previous_domains(arr) ⇒ Object
104 105 106 107 108 109 110 111 112 113 |
# File 'lib/conceptql/fake_annotater.rb', line 104 def previous_domains(arr) extract = if arr.first == :recall [fetch_domains(arr[1])].compact elsif arr.last.is_a?(Hash) && arr.last[:left] [arr.last[:left]] else arr.select { |e| e.is_a?(Array) } end extract.map { |e| e.last[:annotation][:counts].keys }.flatten.compact.uniq end |
#recorded_domains ⇒ Object
125 126 127 |
# File 'lib/conceptql/fake_annotater.rb', line 125 def recorded_domains @recorded_domains ||= {} end |
#save_domains(op) ⇒ Object
119 120 121 122 123 |
# File 'lib/conceptql/fake_annotater.rb', line 119 def save_domains(op) label = op.last[:label] return unless label recorded_domains[label] = op end |
#traverse(stmt) ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/conceptql/fake_annotater.rb', line 74 def traverse(stmt) stmt.recurse(Array, Hash) do |arr_or_hash| if arr_or_hash.is_a?(Array) arr_or_hash.unshift(arr_or_hash.shift.to_sym) domains = DOMAINS[arr_or_hash.first.to_sym] unless domains domains = previous_domains(arr_or_hash) else domains = [domains].flatten end annotate_hash = if arr_or_hash.last.is_a?(Hash) arr_or_hash.last[:annotation] ||= {} else annotate_hash = {} arr_or_hash.push(annotation: annotate_hash) annotate_hash end annotate_hash[:counts] = {} domains.each do |domain| annotate_hash[:counts][domain] = {} end save_domains(arr_or_hash) else arr_or_hash.deep_rekey! arr_or_hash[:annotation] ||= {} end arr_or_hash end end |