Class: Aqueduct::Wrappers::I2b2
- Inherits:
-
Object
- Object
- Aqueduct::Wrappers::I2b2
- Includes:
- Aqueduct::Wrapper
- Defined in:
- lib/aqueduct/wrappers/i2b2.rb
Constant Summary collapse
- DOMAIN =
'i2b2demo'
Instance Method Summary collapse
- #concept_tables(query_concept) ⇒ Object
- #conditions(query_concepts) ⇒ Object
-
#connect ⇒ Object
TODO: Update i2b2 connect to make sure the server is up and running.
- #count(query_concepts, conditions, tables, join_conditions, concept_to_count) ⇒ Object
- #external_concept_information(external_key = '') ⇒ Object
- #external_concepts(folder = '', search_term = '') ⇒ Object
- #query(sql_statement) ⇒ Object
- #use_sql? ⇒ Boolean
Instance Method Details
#concept_tables(query_concept) ⇒ Object
61 62 63 |
# File 'lib/aqueduct/wrappers/i2b2.rb', line 61 def concept_tables(query_concept) { result: [], error: '' } end |
#conditions(query_concepts) ⇒ Object
65 66 67 |
# File 'lib/aqueduct/wrappers/i2b2.rb', line 65 def conditions(query_concepts) { conditions: "#{query_concepts.collect{|qc| qc.id}}", error: '' } end |
#connect ⇒ Object
TODO: Update i2b2 connect to make sure the server is up and running
110 111 112 |
# File 'lib/aqueduct/wrappers/i2b2.rb', line 110 def connect true end |
#count(query_concepts, conditions, tables, join_conditions, concept_to_count) ⇒ Object
53 54 55 |
# File 'lib/aqueduct/wrappers/i2b2.rb', line 53 def count(query_concepts, conditions, tables, join_conditions, concept_to_count) get_total_count(query_concepts.find_all_by_id(eval(conditions))) end |
#external_concept_information(external_key = '') ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/aqueduct/wrappers/i2b2.rb', line 21 def external_concept_information(external_key = '') error = '' result = {} service_url = '/i2b2/rest/OntologyService/getTermInfo' xml = ::Builder::XmlMarkup.new xml.instruct! :xml, standalone: 'yes' xml.tag!("ns3:request", "xmlns:ns3" => "http://www.i2b2.org/xsd/hive/msg/1.1/", "xmlns:ns4" => "http://www.i2b2.org/xsd/cell/ont/1.1/", "xmlns:ns2" => "http://www.i2b2.org/xsd/hive/plugin/") do |req| req. do |mhr| mhr << (service_url, 'i2b2 Ontology', 1.6, 'i2b2 Hive', 'Ontology Cell', 1.6, 'i2b2 Hive') end req.request_header do |rqh| rqh.result_waittime_ms 180000 end req. do |mgb| mgb.tag!('ns4:get_term_info', "blob" => "true", "type" => "core", "synonyms" => "true", "hiddens" => "true") do |gti| gti.tag!('self') do |sef| sef.text! external_key end end end end result_hash = process_concepts((xml.target!, service_url)) result = result_hash[:result].first unless result_hash[:result].first.blank? { result: result, error: result_hash[:error] } end |
#external_concepts(folder = '', search_term = '') ⇒ Object
17 18 19 |
# File 'lib/aqueduct/wrappers/i2b2.rb', line 17 def external_concepts(folder = '', search_term = '') search_term.blank? ? get_concepts(folder) : search_for_term(folder, search_term) end |
#query(sql_statement) ⇒ Object
69 70 71 72 73 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 103 104 105 106 107 |
# File 'lib/aqueduct/wrappers/i2b2.rb', line 69 def query(sql_statement) # result = [[['cname', 'cname2', 'cname3', 'cname4'],[1,2,3,4],[5,nil,7,8]],2] result = [[]] concept_list = [] # TODO: Replace this with query_concepts (pass in query concepts initially?) query_concepts = QueryConcept.find_all_by_id(eval(sql_statement)) result_hash = get_all_covariates(query_concepts) result = result_hash[:result] error = result_hash[:error] # THIS WORKS! (For limited ors and non complex things) # query_concepts.each_with_index do |query_concept, index| # concept_list << { key: query_concept.external_key, right_operator: query_concept.right_operator, negated: query_concept.negated } # end # # conditions = query_definition(concept_list) # # patient_data = run_query_get_patient_data(conditions) # # if patient_data.first and patient_data.first[1] # all_concepts = patient_data.first[1].keys # result[0] = ['patient_id'] + all_concepts # end # # patient_data.each_pair do |patient_id, value_hash| # row_data = [patient_id] # all_concepts.each do |concept| # row_data << value_hash[concept][:value] # end # result << row_data # end [result, result.size] end |
#use_sql? ⇒ Boolean
57 58 59 |
# File 'lib/aqueduct/wrappers/i2b2.rb', line 57 def use_sql? false end |