conceptql 0.0.1 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 90f5abb4db48ead54bae29422ee872aae4de8f70
4
- data.tar.gz: afd43782a372f975d0d61d720775874559d415ce
3
+ metadata.gz: 09e9c3738772ff72625b848a26ac0e6d98c8275a
4
+ data.tar.gz: eb7753304d9a505e29c805019c222fe3d7a3119c
5
5
  SHA512:
6
- metadata.gz: 200787dca2b53c9d78e4d20f04ae1a8e3294d874a1ba3056b9c26ee74340928d12a65d5cfc76f404cbc35dea89a3bd5b3238c78d9610ec92f8cd3ae67be02b04
7
- data.tar.gz: aff26e54432f073c260380a6ae3f93dcd5767e899d7de00bace34f2fdd0fac9987170a3261e8ab550e5dac73a8a0a3a1427008a0b1307027b381e7ef1f58c2c9
6
+ metadata.gz: e761811c0bcbcb2745cc5f3c9a0131d83a1b51ad26de632c3c02ca4d0f3b84ce6ba468f454a66a940027289d027747304501f52ecee648f41aa8f57aa91d98d5
7
+ data.tar.gz: 65b907da6c8bddb46d61a772dfc4c965fa1c8c87e3d1729b5ec0175c047b9860043b5760eba9583ce3c2f12d18cfc9dc901114d79a7cae410282e9c6e9dbefd2
data/CHANGELOG.md CHANGED
@@ -1,6 +1,44 @@
1
1
  # Changelog
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ ## 0.0.3 - 2014-08-12
5
+
6
+ ### Added
7
+ - FakeGrapher class to make it easier to generate diagrams with experimental nodes
8
+ - fake_graph command has returned to the `conceptql` program
9
+ - GraphNodifier now supports:
10
+ - condition_type as condition_occurrence
11
+ - drg as procedure_occurrence
12
+ - vsac as misc
13
+
14
+ ### Deprecated
15
+ - Nothing.
16
+
17
+ ### Removed
18
+ - Nothing.
19
+
20
+ ### Fixed
21
+ - Tree now runs #deep_symbolize_keys on incoming statements
22
+
23
+
24
+ ## 0.0.2 - 2014-07-11
25
+
26
+ ### Added
27
+ - Nothing.
28
+
29
+ ### Deprecated
30
+ - Nothing.
31
+
32
+ ### Removed
33
+ - Several commands from `conceptql` program
34
+ - fake_graph
35
+ - show_db_graph
36
+ - show_and_tell_db
37
+
38
+ ### Fixed
39
+ - Nothing.
40
+
41
+
4
42
  ## 0.0.1 - 2014-07-11
5
43
 
6
44
  ### Added
data/README.md CHANGED
@@ -101,6 +101,8 @@ You might want to just take an existing statement from the statements in [test_c
101
101
  4. Push to the branch (`git push origin my-new-feature`)
102
102
  5. Create new Pull Request
103
103
 
104
+ Or, use the [conceptql-dev-box](https://github.com/outcomesinsights/conceptql-dev-box) to get yourself setup and hack on ConceptQL that way.
105
+
104
106
  ## Thanks
105
107
  - [Outcomes Insights, Inc.](http://outins.com)
106
108
  - Many thanks for allowing me to release a portion of my work as Open Source Software!
data/doc/spec.md CHANGED
@@ -1205,4 +1205,14 @@ Filter node is the opposite of Except. It only includes L if R matches.
1205
1205
  ### AS option for Except
1206
1206
  Just like Filter has an :as option, add one to Except node. This would simplify some of the algorithms I've developed.
1207
1207
 
1208
+
1209
+ ### How to Handle fact_relationship Table from CDMv5
1210
+ Each relationship type could be a binary node box read as L <relationship> R. E.g. L 'parent of' R would take a L stream and only pass on parents of rows in R stream.
1211
+
1212
+ We could implement a single node that takes a relationship as an argument (on top of the L and R arguments) or we could create a node class for each relationship. I think it would be better to have a single relationship node class and take the relationship as the argument.
1213
+
1214
+ The next question is: how do we actually join the two streams? I suppose we could translate each "type" into a "domain" and then join where l.domain = domain_concept_id_1 and l.entity_id = fact_id_1 and R.domain = domain_concept_id_2 and R.entity_id = fact_id_2 where the relationship chosen = relationship_concept_id.
1215
+
1216
+ Yup, that should work. Phew!
1217
+
1208
1218
  [^AIA]: J. Allen. Maintaining knowledge about temporal intervals. Communications of the ACM (1983) vol. 26 (11) pp. 832-843
data/lib/conceptql/cli.rb CHANGED
@@ -34,7 +34,7 @@ module ConceptQL
34
34
  aliases: :s,
35
35
  desc: 'schema for database (PostgreSQL only)'
36
36
 
37
- desc 'run_statement statement_file', 'Evals the statement from the statement file and executes it agains the DB specified by DB_URL'
37
+ desc 'run_statement statement_file', 'Reads the ConceptQL statement from the statement file and executes it against the DB'
38
38
  def run_statement(statement_file)
39
39
  q = ConceptQL::Query.new(db(options), criteria_from_file(statement_file))
40
40
  puts q.query.sql
@@ -42,29 +42,25 @@ module ConceptQL
42
42
  pp q.execute
43
43
  end
44
44
 
45
- desc 'fake_graph file', 'Evals the file and shows the contents as a ConceptQL graph'
46
- def fake_graph(file)
47
- require_relative 'graph'
48
- require_relative 'tree'
49
- require_relative 'graph_nodifier'
50
- ConceptQL::Graph.new(criteria_from_file(file),
51
- dangler: true,
52
- tree: ConceptQL::Tree.new(nodifier: ConceptQL::GraphNodifier.new)
53
- ).graph_it('/tmp/graph')
54
- system('open /tmp/graph.pdf')
55
- end
56
-
57
- desc 'show_graph file', 'Evals the file and shows the contents as a ConceptQL graph'
45
+ desc 'show_graph statement_file', 'Reads the ConceptQL statement from the file and shows the contents as a ConceptQL graph'
58
46
  def show_graph(file)
59
47
  graph_it(criteria_from_file(file))
60
48
  end
61
49
 
62
- desc 'show_and_tell_file file', 'Evals the file and shows the contents as a ConceptQL graph, then executes the statement against our test database'
50
+ desc 'show_and_tell_file statement_file', 'Reads the ConceptQL statement from the file and shows the contents as a ConceptQL graph, then executes the statement against the DB'
63
51
  option :full
64
- def show_and_tell_file(file)
52
+ def show_and_tell(file)
65
53
  show_and_tell(criteria_from_file(file), options)
66
54
  end
67
55
 
56
+ desc 'fake_graph file', 'Reads the ConceptQL statement from the file and shows the contents as a ConceptQL graph'
57
+ def fake_graph(file)
58
+ require_relative 'fake_grapher'
59
+ ConceptQL::FakeGrapher.new.graph_it(criteria_from_file(file), '/tmp/graph')
60
+ system('open /tmp/graph.pdf')
61
+ end
62
+
63
+ private
68
64
  desc 'show_and_tell_db conceptql_id', 'Fetches the ConceptQL from a DB and shows the contents as a ConceptQL graph, then executes the statement against our test database'
69
65
  option :full
70
66
  def show_and_tell_db(conceptql_id)
@@ -79,7 +75,6 @@ module ConceptQL
79
75
  graph_it(result[:statement].to_hash, db, result[:label])
80
76
  end
81
77
 
82
- private
83
78
  def fetch_conceptql(conceptql_id)
84
79
  my_db = db(options)
85
80
  my_db.extension(:pg_array, :pg_json)
@@ -0,0 +1,20 @@
1
+ require_relative 'graph'
2
+ require_relative 'tree'
3
+ require_relative 'graph_nodifier'
4
+
5
+ module ConceptQL
6
+ class FakeGrapher
7
+ attr :options
8
+
9
+ def initialize(options = {})
10
+ @options = {
11
+ dangler: true,
12
+ tree: ConceptQL::Tree.new(nodifier: ConceptQL::GraphNodifier.new)
13
+ }.merge(options)
14
+ end
15
+
16
+ def graph_it(statement, output_file)
17
+ ConceptQL::Graph.new(statement, options).graph_it(output_file)
18
+ end
19
+ end
20
+ end
@@ -11,10 +11,12 @@ module ConceptQL
11
11
  condition: :condition_occurrence,
12
12
  primary_diagnosis: :condition_occurrence,
13
13
  icd9: :condition_occurrence,
14
+ condition_type: :condition_occurrence,
14
15
 
15
16
  # Procedures
16
17
  procedure: :procedure_occurrence,
17
18
  cpt: :procedure_occurrence,
19
+ drg: :procedure_occurrence,
18
20
  hcpcs: :procedure_occurrence,
19
21
  icd9_procedure: :procedure_occurrence,
20
22
  procedure_cost: :procedure_cost,
@@ -45,7 +47,8 @@ module ConceptQL
45
47
  date_range: :date,
46
48
 
47
49
  # Miscelaneous nodes
48
- concept: :misc
50
+ concept: :misc,
51
+ vsac: :misc
49
52
  }
50
53
 
51
54
  attr :values, :name
@@ -78,10 +81,14 @@ module ConceptQL
78
81
  class BinaryOperatorNode < DotNode
79
82
  def display_name
80
83
  output = name
81
- output += "\n#{options.map{|k,v| "#{k}: #{v}"}.join("\n")}" unless options.nil? || options.empty?
84
+ output += "\n#{displayable_options.map{|k,v| "#{k}: #{v}"}.join("\n")}"
82
85
  output
83
86
  end
84
87
 
88
+ def displayable_options
89
+ options.select{ |k,v| ![:left, :right].include?(k) } || {}
90
+ end
91
+
85
92
  def left
86
93
  options[:left]
87
94
  end
@@ -116,7 +123,9 @@ module ConceptQL
116
123
  BINARY_OPERATOR_TYPES = %w(before after meets met_by started_by starts contains during overlaps overlapped_by finished_by finishes coincides except person_filter less_than less_than_or_equal equal not_equal greater_than greater_than_or_equal filter).map { |temp| [temp, "not_#{temp}"] }.flatten.map(&:to_sym)
117
124
 
118
125
  def create(type, values)
119
- return BinaryOperatorNode.new(type, values) if BINARY_OPERATOR_TYPES.include?(type)
126
+ if BINARY_OPERATOR_TYPES.include?(type)
127
+ return BinaryOperatorNode.new(type, values)
128
+ end
120
129
  DotNode.new(type, values)
121
130
  end
122
131
  end
@@ -10,7 +10,7 @@ module ConceptQL
10
10
  end
11
11
 
12
12
  def root(query)
13
- @root ||= traverse(query.statement.symbolize_keys)
13
+ @root ||= traverse(query.statement.deep_symbolize_keys)
14
14
  end
15
15
 
16
16
  private
@@ -1,3 +1,3 @@
1
1
  module ConceptQL
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: conceptql
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Duryea
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-11 00:00:00.000000000 Z
11
+ date: 2014-08-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -161,6 +161,7 @@ files:
161
161
  - lib/conceptql/behaviors/dottable.rb
162
162
  - lib/conceptql/cli.rb
163
163
  - lib/conceptql/date_adjuster.rb
164
+ - lib/conceptql/fake_grapher.rb
164
165
  - lib/conceptql/graph.rb
165
166
  - lib/conceptql/graph_nodifier.rb
166
167
  - lib/conceptql/logger.rb