conceptql 0.7.0 → 0.8.0
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 +4 -4
- data/CHANGELOG.md +155 -0
- data/README.md +4 -0
- data/config/vocabularies.csv +1 -0
- data/docs/spec/README.md +5 -3
- data/docs/spec/examples/recall-operator.json +6 -3
- data/lib/conceptql/annotation.rb +136 -0
- data/lib/conceptql/behaviors/provenanceable.rb +44 -26
- data/lib/conceptql/cli.rb +0 -6
- data/lib/conceptql/database.rb +74 -4
- data/lib/conceptql/diagram.rb +4 -1
- data/lib/conceptql/diagram_renderer/geometry.rb +6 -1
- data/lib/conceptql/lexicon/lexicon_strategy.rb +23 -12
- data/lib/conceptql/lexicon.rb +24 -35
- data/lib/conceptql/nodifier.rb +16 -0
- data/lib/conceptql/operators/co_reported.rb +1 -0
- data/lib/conceptql/operators/information_periods.rb +7 -3
- data/lib/conceptql/operators/multiple_vocabularies.rb +42 -22
- data/lib/conceptql/operators/operator.rb +38 -8
- data/lib/conceptql/operators/place_of_service_filter.rb +24 -12
- data/lib/conceptql/operators/provenance.rb +11 -11
- data/lib/conceptql/operators/recall.rb +5 -0
- data/lib/conceptql/operators/union.rb +13 -2
- data/lib/conceptql/operators/vocabulary.rb +73 -24
- data/lib/conceptql/query.rb +111 -37
- data/lib/conceptql/scope.rb +1 -18
- data/lib/conceptql/version.rb +1 -1
- data/lib/conceptql/vocabularies/drg_systems.rb +3 -3
- data/lib/conceptql/vocabularies/dynamic_vocabularies.rb +15 -10
- data/lib/conceptql/vocabularies/entry.rb +2 -2
- data/lib/conceptql/vocabularies/read_codes.rb +42 -0
- data/lib/conceptql/vocabularies/vocabulary_class_factory.rb +3 -0
- metadata +3 -3
- data/lib/conceptql/lexicon/lexicon_gdm.rb +0 -50
- data/lib/conceptql/operators/read.rb +0 -79
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require_relative "lexicon_strategy"
|
|
4
|
-
|
|
5
|
-
module ConceptQL
|
|
6
|
-
class LexiconGDM < LexiconStrategy
|
|
7
|
-
# The GDM vocabulary tables. A db that has all four can be the lexicon.
|
|
8
|
-
VOCABULARY_TABLES = %i[ancestors concepts mappings vocabularies].freeze
|
|
9
|
-
|
|
10
|
-
class << self
|
|
11
|
-
def db_has_all_vocabulary_tables?(db)
|
|
12
|
-
VOCABULARY_TABLES.all? { |t| db.table_exists?(t) }
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def vocabularies_query
|
|
17
|
-
db[:vocabularies]
|
|
18
|
-
.select(Sequel[:id].as(:id),
|
|
19
|
-
Sequel[:id].as(:omopv5_vocabulary_id),
|
|
20
|
-
Sequel[:vocabulary_name].as(:vocabulary_short_name),
|
|
21
|
-
Sequel[:vocabulary_name].as(:vocabulary_full_name),
|
|
22
|
-
Sequel[:domain],
|
|
23
|
-
Sequel.expr(1).as(:from_lexicon))
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def vocabularies
|
|
27
|
-
vocabularies_query.all
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def is_a_relationships(_data_db)
|
|
31
|
-
db[:mappings].where { Sequel.function(:lower, :relationship_id) =~ "is_a" }
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
def ancestors_table(_data_db)
|
|
35
|
-
db[:ancestors]
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def concepts_table(_data_db, _some_schema = nil)
|
|
39
|
-
db[:concepts]
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def table_is_missing?(_data_db)
|
|
43
|
-
!db.table_exists?(:concepts)
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
def strategy
|
|
47
|
-
:gdm
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
end
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "sequel"
|
|
4
|
-
require "sequel/adapters/mock"
|
|
5
|
-
require_relative "../behaviors/labish"
|
|
6
|
-
require_relative "vocabulary"
|
|
7
|
-
|
|
8
|
-
module ConceptQL
|
|
9
|
-
module Operators
|
|
10
|
-
class Read < Operator
|
|
11
|
-
include ConceptQL::Behaviors::CodeLister
|
|
12
|
-
extend Vocabulary::SharedDocumentation
|
|
13
|
-
register __FILE__
|
|
14
|
-
|
|
15
|
-
preferred_name "READ"
|
|
16
|
-
# The vocabulary_name of Read in the OHDSI vocabulary table
|
|
17
|
-
long_name "NHS UK Read Codes Version 2 (HSCIC)"
|
|
18
|
-
# Metadata only: the records come from ReadGDM, which selects condition_occurrence
|
|
19
|
-
predominant_domains :condition_occurrence
|
|
20
|
-
desc "Selects records based on the Read vocabulary."
|
|
21
|
-
argument :read_codes, type: :codelist, vocab: "Read",
|
|
22
|
-
meaning: "One or more Read codes. Write each code as the Read vocabulary writes it. " \
|
|
23
|
-
"A code matches exactly, including case, and it does not select its child codes. " \
|
|
24
|
-
"A code alone of * selects every Read record."
|
|
25
|
-
basic_type :selection
|
|
26
|
-
validate_no_upstreams
|
|
27
|
-
category "Select by Clinical Codes"
|
|
28
|
-
conceptql_spec_id "vocabulary"
|
|
29
|
-
|
|
30
|
-
def query(db)
|
|
31
|
-
ops(db).first.evaluate(db)
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
def domains(db)
|
|
35
|
-
ops.first.domains(db)
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def query_cols
|
|
39
|
-
ops.first.query_cols
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def required_columns
|
|
43
|
-
ops.flat_map(&:required_columns).uniq
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
private
|
|
47
|
-
|
|
48
|
-
def ops(_db = nil)
|
|
49
|
-
[ ReadGDM.new(nodifier, "read_condition_occurrence", *arguments) ]
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
def describe_codes(db, codes)
|
|
53
|
-
ops.flat_map { |op| op.describe_codes(db, codes) }
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
class ReadBase < ConceptQL::Operators::Vocabulary
|
|
57
|
-
preferred_name "READ"
|
|
58
|
-
argument :read_codes, type: :codelist, vocab: "Read"
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
class ReadGDM < ReadBase
|
|
62
|
-
include ConceptQL::Vocabularies::Behaviors::Gdmish
|
|
63
|
-
include ConceptQL::Behaviors::Labish
|
|
64
|
-
|
|
65
|
-
def vocabulary_id
|
|
66
|
-
"Read"
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
def domain_map(_v_id)
|
|
70
|
-
:condition_occurrence
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
def domains(_db)
|
|
74
|
-
[ :condition_occurrence ]
|
|
75
|
-
end
|
|
76
|
-
end
|
|
77
|
-
end
|
|
78
|
-
end
|
|
79
|
-
end
|