loadmop 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/CHANGELOG.md +30 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +22 -0
- data/README.md +105 -0
- data/Rakefile +2 -0
- data/bin/loadmop +4 -0
- data/config/database.yml.example +2 -0
- data/lib/loadmop.rb +5 -0
- data/lib/loadmop/cdmv4_loader.rb +54 -0
- data/lib/loadmop/cli.rb +23 -0
- data/lib/loadmop/loader.rb +169 -0
- data/lib/loadmop/version.rb +3 -0
- data/lib/loadmop/vocab_loader.rb +17 -0
- data/loadmop.gemspec +25 -0
- data/schemas/cdmv4/001_tables.rb +256 -0
- data/schemas/cdmv4/002_indexes.rb +145 -0
- data/schemas/vocabulary/001_tables.rb +96 -0
- data/schemas/vocabulary/002_indexes.rb +24 -0
- metadata +122 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: cdf767e8d88611fc7c22d76f75fdd7d84f26243a
|
4
|
+
data.tar.gz: 82a718413d1ad1ea267713fe341329f08bd47b2b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 225f8f6fd5d8ad11322d54bbe0c8523ede5048a4417dd51e751335fec70e38c4b812c4769cc5c1f968138da0cadc295daf3c94c0935496f85222cbb4d4041bdf
|
7
|
+
data.tar.gz: 5f4c71425f17b4c045a139da9cc18c325571a328e86c91b94897441070228d9e093075b1d7a002ce82aa0dac6825073020ba88bcf03d38e55211b3eb5dfd1ff8
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# Changelog
|
2
|
+
All notable changes to this project will be documented in this file.
|
3
|
+
|
4
|
+
## 0.0.2 - 2014-07-11
|
5
|
+
|
6
|
+
### Added
|
7
|
+
- Nothing.
|
8
|
+
|
9
|
+
### Deprecated
|
10
|
+
- Nothing.
|
11
|
+
|
12
|
+
### Removed
|
13
|
+
- Nothing.
|
14
|
+
|
15
|
+
### Fixed
|
16
|
+
- Bug where schemas directory was not found when loadmop was installed as a gem
|
17
|
+
|
18
|
+
## 0.0.1 - 2014-07-10
|
19
|
+
|
20
|
+
### Added
|
21
|
+
- This project
|
22
|
+
|
23
|
+
### Deprecated
|
24
|
+
- Nothing.
|
25
|
+
|
26
|
+
### Removed
|
27
|
+
- Nothing.
|
28
|
+
|
29
|
+
### Fixed
|
30
|
+
- Nothing.
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Outcomes Insights, Inc.
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
# Loadmop
|
2
|
+
|
3
|
+
Helps load up the OMOP [Vocabulary](http://imeds.reaganudall.org/Vocabularies)/[CDM](http://omop.org/CDM) into the database of your choice.
|
4
|
+
|
5
|
+
## Requirements
|
6
|
+
|
7
|
+
- Ruby 2.0+
|
8
|
+
- [Bundler](http://bundler.io/)
|
9
|
+
- Some sort of RDBMS to store OMOP Vocabulary files in
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
Add this line to your application's Gemfile:
|
14
|
+
|
15
|
+
gem 'loadmop'
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
$ bundle
|
20
|
+
|
21
|
+
Or install it yourself as:
|
22
|
+
|
23
|
+
$ gem install loadmop
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
Run `bundle exec loadmop` with no arguments to get a help screen and figure out which command you want to run
|
27
|
+
|
28
|
+
### Preparation
|
29
|
+
Create a .env file in the root directory of the clone, specifying:
|
30
|
+
|
31
|
+
- SEQUELIZER_DATABASE
|
32
|
+
- The name of the database you want to install to
|
33
|
+
- Required
|
34
|
+
- SEQUELIZER_ADAPTER
|
35
|
+
- The name of the adapter to use (e.g. postgres, sqlite, mysql, oracle)
|
36
|
+
- Required
|
37
|
+
- SEQUELIZER_HOST
|
38
|
+
- The host on which the database lives
|
39
|
+
- Optional
|
40
|
+
- SEQUELIZER_USERNAME
|
41
|
+
- The username to connect to the database with
|
42
|
+
- Optional
|
43
|
+
- SEQUELIZER_PASSWORD
|
44
|
+
- The password to connect to the database with
|
45
|
+
- Optional
|
46
|
+
- SEQUELIZER_SEARCH_PATH
|
47
|
+
- At least for PostgreSQL, specifies a schema to install into
|
48
|
+
- Optional
|
49
|
+
|
50
|
+
See the [Sequelizer Gem](https://github.com/outcomesinsights/sequelizer) for [some .env examples](https://github.com/outcomesinsights/sequelizer/tree/master/examples)
|
51
|
+
|
52
|
+
Then:
|
53
|
+
|
54
|
+
- **Create the database you just specified in your .env file**
|
55
|
+
- loadmop isn't (yet) cool enough to actually create the database for you
|
56
|
+
- If you're using SQLite, you don't have to create the database file
|
57
|
+
- cd into a directory where you've defined a config/database.yml or .env file that is compatible with Sequelizer
|
58
|
+
- run `bundle install` to make sure you have all the needed dependencies installed
|
59
|
+
- run `bundle exec sequelizer config` to ensure your connection parameters are correctly set
|
60
|
+
- run `bundle exec sequelizer update_gemfile` to ensure your Gemfile has the right database gem
|
61
|
+
|
62
|
+
### Loading Vocabulary Files
|
63
|
+
|
64
|
+
- Download the [OMOP Vocabulary Files](http://vocabbuild.omop.org/vocabulary-release) and unzip them to some directory.
|
65
|
+
- I recommend you use the restricted files since they include CPT codes and other useful vocabularies.
|
66
|
+
- Run `bundle exec loadmop create_vocab_database /path/to/directory/holding/unzipped/vocabulary/files`
|
67
|
+
- This runs all the steps for setting up the vocabulary database, namely
|
68
|
+
- Creating the proper tables
|
69
|
+
- Prepping the CSV files to load into the database
|
70
|
+
- Loading the CSV files into the database
|
71
|
+
- Adding some useful indexes to the vocabulary tables
|
72
|
+
|
73
|
+
|
74
|
+
### Loading CDM Data
|
75
|
+
- Run `bundle exec loadmop create_vocab_database /path/to/directory/holding/cdm/data/files`
|
76
|
+
- This runs all the steps for loading CDM data into a database, namely
|
77
|
+
- Creating the proper CDM tables
|
78
|
+
- Prepping the CSV files to load into the database
|
79
|
+
- Loading the CSV files into the database
|
80
|
+
- Adding some useful indexes to the CDM tables
|
81
|
+
|
82
|
+
## Pleas for Help
|
83
|
+
|
84
|
+
I've written methods to quickly load the data into PostgreSQL and SQLite, but I don't regularly use many other RDBMSs. Right now they use a method that should work for all RDBMSs, but is pretty slow.
|
85
|
+
|
86
|
+
Some of the faster methods are Unix-only as well. If there are fast, platform-independent ways to load the data, I'm interested.
|
87
|
+
|
88
|
+
Please submit suggestions or pull requests to speed up loading under other RDBMSs and I'll incorporate them. Thanks!
|
89
|
+
|
90
|
+
## Contributing
|
91
|
+
|
92
|
+
1. Fork it ( https://github.com/outcomesinsights/loadmop/fork )
|
93
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
94
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
95
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
96
|
+
5. Create a new Pull Request
|
97
|
+
|
98
|
+
## Thanks
|
99
|
+
|
100
|
+
- [Outcomes Insights, Inc.](http://outins.com)
|
101
|
+
- Many thanks for allowing me to release a portion of my work as Open Source Software!
|
102
|
+
- [IMEDS](http://imeds.reaganudall.org/Vocabularies)/[OMOP](http://omop.org)/[OHDSI](http://ohdsi.org)
|
103
|
+
- For developing the vocabulary files. What a fantastic resource!
|
104
|
+
- [OMOP](http://omop.org)/[OHDSI](http://ohdsi.org)
|
105
|
+
- For developing their [CDM](http://omop.org/CDM)
|
data/Rakefile
ADDED
data/bin/loadmop
ADDED
data/lib/loadmop.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
require_relative 'loader'
|
2
|
+
|
3
|
+
module Loadmop
|
4
|
+
class CDMv4Loader < Loader
|
5
|
+
|
6
|
+
def initialize(*args)
|
7
|
+
super(*args)
|
8
|
+
set_schema_if_necessary
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def schemas_dir
|
14
|
+
'schemas/cdmv4'
|
15
|
+
end
|
16
|
+
|
17
|
+
def files
|
18
|
+
ordered_file_names.map { |name| data_files_dir + name }.select(&:exist?)
|
19
|
+
end
|
20
|
+
|
21
|
+
def set_schema_if_necessary
|
22
|
+
return unless adapter == 'postgres'
|
23
|
+
return unless options[:schema]
|
24
|
+
db.create_schema(options[:schema], if_not_exists: true)
|
25
|
+
db.execute("SET search_path TO #{options[:schema]}")
|
26
|
+
end
|
27
|
+
|
28
|
+
def ordered_tables
|
29
|
+
%w(
|
30
|
+
person
|
31
|
+
visit_occurrence
|
32
|
+
condition_occurrence
|
33
|
+
procedure_occurrence
|
34
|
+
procedure_cost
|
35
|
+
observation
|
36
|
+
observation_period
|
37
|
+
payer_plan_period
|
38
|
+
drug_exposure
|
39
|
+
drug_cost
|
40
|
+
location
|
41
|
+
organization
|
42
|
+
provider
|
43
|
+
care_site
|
44
|
+
condition_era
|
45
|
+
death
|
46
|
+
cohort
|
47
|
+
)
|
48
|
+
end
|
49
|
+
|
50
|
+
def ordered_file_names
|
51
|
+
ordered_tables.map { |f| f + '.csv' }
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
data/lib/loadmop/cli.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require_relative 'cdmv4_loader'
|
3
|
+
require_relative 'vocab_loader'
|
4
|
+
|
5
|
+
module Loadmop
|
6
|
+
class CLI < Thor
|
7
|
+
include Sequelizer
|
8
|
+
|
9
|
+
desc 'create_vocab_database vocab_files_dir', 'Connects to database specified in the .env file and loads the OMOP Vocabulary schema and data into it'
|
10
|
+
def create_vocab_database(vocab_files_dir)
|
11
|
+
loader = VocabLoader.new(vocab_files_dir)
|
12
|
+
loader.create_database
|
13
|
+
end
|
14
|
+
|
15
|
+
desc 'create_cdmv4_data data_dir', 'Creates a schema in a database for OMOP CDMv4 then loads data into it as specified by data_files_dir'
|
16
|
+
option :schema, type: :string, desc: 'PostgreSQL ONLY - specifies the schema within the database that will house the CDM tables and data'
|
17
|
+
def create_cdmv4_database(data_files_dir)
|
18
|
+
cdm_loader = CDMv4Loader.new(data_files_dir, options)
|
19
|
+
cdm_loader.create_database
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
@@ -0,0 +1,169 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
require 'csv'
|
3
|
+
require 'sequelizer'
|
4
|
+
|
5
|
+
module Loadmop
|
6
|
+
class Loader
|
7
|
+
include Sequelizer
|
8
|
+
|
9
|
+
attr :options, :data_files_dir, :headers
|
10
|
+
|
11
|
+
def initialize(data_files_dir, options = {})
|
12
|
+
@data_files_dir = Pathname.new(data_files_dir)
|
13
|
+
@options = options
|
14
|
+
@headers = {}
|
15
|
+
end
|
16
|
+
|
17
|
+
def create_database
|
18
|
+
create_tables
|
19
|
+
load_files
|
20
|
+
create_indexes
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
def create_tables
|
25
|
+
Sequel.extension :migration
|
26
|
+
Sequel::Migrator.run(db, base_dir + schemas_dir, target: 1)
|
27
|
+
end
|
28
|
+
|
29
|
+
def create_indexes
|
30
|
+
Sequel.extension :migration
|
31
|
+
Sequel::Migrator.run(db, base_dir + schemas_dir, target: 2)
|
32
|
+
end
|
33
|
+
|
34
|
+
def all_files
|
35
|
+
@all_files ||= make_all_files
|
36
|
+
end
|
37
|
+
|
38
|
+
def load_files
|
39
|
+
fast_load || slow_load
|
40
|
+
end
|
41
|
+
|
42
|
+
def fast_load
|
43
|
+
case adapter
|
44
|
+
when 'postgres'
|
45
|
+
fast_load_postgres
|
46
|
+
when 'sqlite'
|
47
|
+
fast_load_sqlite
|
48
|
+
else
|
49
|
+
nil
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def fast_load_postgres
|
54
|
+
all_files.each do |table_name, files|
|
55
|
+
db[table_name].truncate(cascade: true)
|
56
|
+
files.each do |file|
|
57
|
+
puts "Loading #{file} into #{table_name}"
|
58
|
+
db.copy_into(
|
59
|
+
table_name,
|
60
|
+
format: :csv,
|
61
|
+
columns: headers[table_name],
|
62
|
+
data: File.read(file)
|
63
|
+
)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
true
|
67
|
+
end
|
68
|
+
|
69
|
+
def fast_load_sqlite
|
70
|
+
return nil if `which sqlite3` =~ /not found/i
|
71
|
+
all_files.each do |table_name, files|
|
72
|
+
run_sqlite_commands(%Q(DELETE FROM #{table_name};))
|
73
|
+
commands = []
|
74
|
+
commands << %Q(.echo on)
|
75
|
+
commands << %Q(.log stdout)
|
76
|
+
commands << %Q(.mode csv)
|
77
|
+
commands << "placeholder"
|
78
|
+
files.each do |file|
|
79
|
+
puts "Loading #{file} into #{table_name}"
|
80
|
+
commands.pop
|
81
|
+
commands << ".import #{file} #{table_name}"
|
82
|
+
run_sqlite_commands(commands)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
true
|
86
|
+
end
|
87
|
+
|
88
|
+
def run_sqlite_commands(*commands)
|
89
|
+
db_file_path = database
|
90
|
+
File.open('/tmp/sqlite.load', 'w') do |command_file|
|
91
|
+
command_file.puts commands.flatten.join("\n")
|
92
|
+
end
|
93
|
+
command = "sqlite3 #{db_file_path} '.read /tmp/sqlite.load'"
|
94
|
+
puts command
|
95
|
+
system(command)
|
96
|
+
end
|
97
|
+
|
98
|
+
def slow_load
|
99
|
+
all_files.each do |table_name, files|
|
100
|
+
files.each do |file|
|
101
|
+
puts "Loading #{file} into #{table_name}"
|
102
|
+
CSV.open(file, headers: true) do |csv|
|
103
|
+
csv.each_slice(1000) do |rows|
|
104
|
+
print '.'
|
105
|
+
db[table_name].import(headers_for(file), rows.map(&:fields))
|
106
|
+
end
|
107
|
+
end
|
108
|
+
puts
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
def adapter
|
114
|
+
db.sequelizer_options.adapter
|
115
|
+
end
|
116
|
+
|
117
|
+
def database
|
118
|
+
db.sequelizer_options.database
|
119
|
+
end
|
120
|
+
|
121
|
+
def headers_for(file)
|
122
|
+
header_line = File.open(file, &:readline).downcase.gsub(/\|$/, '')
|
123
|
+
CSV.parse(header_line).first.map(&:to_sym)
|
124
|
+
end
|
125
|
+
|
126
|
+
def files_of_interest
|
127
|
+
Pathname.glob(data_files_dir + '*.csv')
|
128
|
+
end
|
129
|
+
|
130
|
+
def lines_per_split
|
131
|
+
100000
|
132
|
+
end
|
133
|
+
|
134
|
+
def additional_cleaning_steps
|
135
|
+
[]
|
136
|
+
end
|
137
|
+
|
138
|
+
def make_all_files
|
139
|
+
split_dir = data_files_dir + 'split'
|
140
|
+
split_dir.mkdir unless split_dir.exist?
|
141
|
+
files = files_of_interest.map do |file|
|
142
|
+
table_name = file.basename('.*').to_s.downcase.to_sym
|
143
|
+
headers[table_name] = headers_for(file)
|
144
|
+
dir = split_dir + table_name.to_s
|
145
|
+
unless dir.exist?
|
146
|
+
dir.mkdir
|
147
|
+
Dir.chdir(dir) do
|
148
|
+
puts "Splitting #{file}"
|
149
|
+
steps = []
|
150
|
+
steps << "tail -n +2 #{file.expand_path}"
|
151
|
+
steps += additional_cleaning_steps
|
152
|
+
steps << "split -a 5 -l #{lines_per_split}"
|
153
|
+
system(steps.compact.join(" | "))
|
154
|
+
end
|
155
|
+
end
|
156
|
+
[table_name, dir.children.sort]
|
157
|
+
end
|
158
|
+
|
159
|
+
Hash[files]
|
160
|
+
end
|
161
|
+
|
162
|
+
# When installed as a gem, we need to find where the gem is installed
|
163
|
+
# and look for files relative to that path. base_dir returns the
|
164
|
+
# path to the loadmop gem
|
165
|
+
def base_dir
|
166
|
+
Pathname.new(__FILE__).dirname + '../..'
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
data/loadmop.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'loadmop/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'loadmop'
|
8
|
+
spec.version = Loadmop::VERSION
|
9
|
+
spec.authors = ['Ryan Duryea']
|
10
|
+
spec.email = ['aguynamedryan@gmail.com']
|
11
|
+
spec.summary = %q{Ruby-based script to load OMOP Vocabulary/CDMv4 data into a database}
|
12
|
+
spec.description = %q{loadmop assits in loading OMOP Vocabulary files and OMOP CDMv4-compatible CSV files into your database}
|
13
|
+
spec.homepage = 'https://github.com/outcomesinsights/loadmop'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_development_dependency 'bundler', '~> 1.6'
|
22
|
+
spec.add_dependency 'rake', '~> 10.3'
|
23
|
+
spec.add_dependency 'sequelizer', '~> 0.0'
|
24
|
+
spec.add_dependency 'thor', '~> 0.19'
|
25
|
+
end
|
@@ -0,0 +1,256 @@
|
|
1
|
+
Sequel.migration do
|
2
|
+
change do
|
3
|
+
create_table(:care_site, :ignore_index_errors=>true) do
|
4
|
+
Bignum :care_site_id, :null=>false
|
5
|
+
Bignum :location_id, :null=>false
|
6
|
+
Bignum :organization_id, :null=>false
|
7
|
+
Bignum :place_of_service_concept_id
|
8
|
+
String :care_site_source_value, :size=>50
|
9
|
+
String :place_of_service_source_value, :size=>50, :null=>false
|
10
|
+
|
11
|
+
primary_key [:care_site_id]
|
12
|
+
end
|
13
|
+
|
14
|
+
create_table(:cohort, :ignore_index_errors=>true) do
|
15
|
+
Bignum :cohort_id, :null=>false
|
16
|
+
Bignum :cohort_concept_id, :null=>false
|
17
|
+
Date :cohort_start_date, :null=>false
|
18
|
+
Date :cohort_end_date
|
19
|
+
Bignum :subject_id, :null=>false
|
20
|
+
String :stop_reason, :size=>20
|
21
|
+
|
22
|
+
primary_key [:cohort_id]
|
23
|
+
end
|
24
|
+
|
25
|
+
create_table(:location, :ignore_index_errors=>true) do
|
26
|
+
Bignum :location_id, :null=>false
|
27
|
+
String :address_1, :size=>50
|
28
|
+
String :address_2, :size=>50
|
29
|
+
String :city, :size=>50
|
30
|
+
String :state, :size=>2, :fixed=>true
|
31
|
+
String :zip, :size=>9
|
32
|
+
String :county, :size=>20
|
33
|
+
String :location_source_value, :size=>50
|
34
|
+
|
35
|
+
primary_key [:location_id]
|
36
|
+
end
|
37
|
+
|
38
|
+
create_table(:provider, :ignore_index_errors=>true) do
|
39
|
+
Bignum :provider_id, :null=>false
|
40
|
+
String :npi, :size=>20
|
41
|
+
String :dea, :size=>20
|
42
|
+
Bignum :specialty_concept_id
|
43
|
+
Bignum :care_site_id, :null=>false
|
44
|
+
String :provider_source_value, :size=>50, :null=>false
|
45
|
+
String :specialty_source_value, :size=>50
|
46
|
+
|
47
|
+
primary_key [:provider_id]
|
48
|
+
end
|
49
|
+
|
50
|
+
create_table(:organization, :ignore_index_errors=>true) do
|
51
|
+
Bignum :organization_id, :null=>false
|
52
|
+
Bignum :place_of_service_concept_id
|
53
|
+
foreign_key :location_id, :location, :type=>Bignum, :key=>[:location_id]
|
54
|
+
String :organization_source_value, :size=>50, :null=>false
|
55
|
+
String :place_of_service_source_value, :size=>50
|
56
|
+
|
57
|
+
primary_key [:organization_id]
|
58
|
+
end
|
59
|
+
|
60
|
+
create_table(:person, :ignore_index_errors=>true) do
|
61
|
+
Bignum :person_id, :null=>false
|
62
|
+
Bignum :gender_concept_id, :null=>false
|
63
|
+
Integer :year_of_birth, :null=>false
|
64
|
+
Integer :month_of_birth
|
65
|
+
Integer :day_of_birth
|
66
|
+
Bignum :race_concept_id
|
67
|
+
Bignum :ethnicity_concept_id
|
68
|
+
foreign_key :location_id, :location, :type=>Bignum, :key=>[:location_id]
|
69
|
+
foreign_key :provider_id, :provider, :type=>Bignum, :key=>[:provider_id]
|
70
|
+
Bignum :care_site_id
|
71
|
+
String :person_source_value, :size=>50
|
72
|
+
String :gender_source_value, :size=>50
|
73
|
+
String :race_source_value, :size=>50
|
74
|
+
String :ethnicity_source_value, :size=>50
|
75
|
+
|
76
|
+
primary_key [:person_id]
|
77
|
+
end
|
78
|
+
|
79
|
+
create_table(:condition_era, :ignore_index_errors=>true) do
|
80
|
+
Bignum :condition_era_id, :null=>false
|
81
|
+
foreign_key :person_id, :person, :type=>Bignum, :null=>false, :key=>[:person_id]
|
82
|
+
Bignum :condition_concept_id, :null=>false
|
83
|
+
Date :condition_era_start_date, :null=>false
|
84
|
+
Date :condition_era_end_date, :null=>false
|
85
|
+
Bignum :condition_type_concept_id, :null=>false
|
86
|
+
Integer :condition_occurrence_count
|
87
|
+
|
88
|
+
primary_key [:condition_era_id]
|
89
|
+
end
|
90
|
+
|
91
|
+
create_table(:condition_occurrence, :ignore_index_errors=>true) do
|
92
|
+
Bignum :condition_occurrence_id, :null=>false
|
93
|
+
foreign_key :person_id, :person, :type=>Bignum, :null=>false, :key=>[:person_id]
|
94
|
+
Bignum :condition_concept_id, :null=>false
|
95
|
+
Date :condition_start_date, :null=>false
|
96
|
+
Date :condition_end_date
|
97
|
+
Bignum :condition_type_concept_id, :null=>false
|
98
|
+
String :stop_reason, :size=>20
|
99
|
+
Bignum :associated_provider_id
|
100
|
+
Bignum :visit_occurrence_id
|
101
|
+
String :condition_source_value, :size=>50
|
102
|
+
|
103
|
+
primary_key [:condition_occurrence_id]
|
104
|
+
end
|
105
|
+
|
106
|
+
create_table(:death, :ignore_index_errors=>true) do
|
107
|
+
foreign_key :person_id, :person, :type=>Bignum, :null=>false, :key=>[:person_id]
|
108
|
+
Date :death_date, :null=>false
|
109
|
+
Bignum :death_type_concept_id, :null=>false
|
110
|
+
Bignum :cause_of_death_concept_id
|
111
|
+
String :cause_of_death_source_value, :size=>50
|
112
|
+
|
113
|
+
primary_key [:person_id]
|
114
|
+
end
|
115
|
+
|
116
|
+
create_table(:drug_era, :ignore_index_errors=>true) do
|
117
|
+
Bignum :drug_era_id, :null=>false
|
118
|
+
foreign_key :person_id, :person, :type=>Bignum, :null=>false, :key=>[:person_id]
|
119
|
+
Bignum :drug_concept_id, :null=>false
|
120
|
+
Date :drug_era_start_date, :null=>false
|
121
|
+
Date :drug_era_end_date, :null=>false
|
122
|
+
Bignum :drug_type_concept_id, :null=>false
|
123
|
+
Integer :drug_exposure_count
|
124
|
+
|
125
|
+
primary_key [:drug_era_id]
|
126
|
+
end
|
127
|
+
|
128
|
+
create_table(:drug_exposure, :ignore_index_errors=>true) do
|
129
|
+
Bignum :drug_exposure_id, :null=>false
|
130
|
+
foreign_key :person_id, :person, :type=>Bignum, :null=>false, :key=>[:person_id]
|
131
|
+
Bignum :drug_concept_id, :null=>false
|
132
|
+
Date :drug_exposure_start_date, :null=>false
|
133
|
+
Date :drug_exposure_end_date
|
134
|
+
Bignum :drug_type_concept_id, :null=>false
|
135
|
+
String :stop_reason, :size=>20
|
136
|
+
Integer :refills
|
137
|
+
Integer :quantity
|
138
|
+
Integer :days_supply
|
139
|
+
String :sig, :size=>500
|
140
|
+
Bignum :prescribing_provider_id
|
141
|
+
Bignum :visit_occurrence_id
|
142
|
+
Bignum :relevant_condition_concept_id
|
143
|
+
String :drug_source_value, :size=>50
|
144
|
+
|
145
|
+
primary_key [:drug_exposure_id]
|
146
|
+
end
|
147
|
+
|
148
|
+
create_table(:observation, :ignore_index_errors=>true) do
|
149
|
+
Bignum :observation_id, :null=>false
|
150
|
+
foreign_key :person_id, :person, :type=>Bignum, :null=>false, :key=>[:person_id]
|
151
|
+
Bignum :observation_concept_id, :null=>false
|
152
|
+
Date :observation_date, :null=>false
|
153
|
+
Date :observation_time
|
154
|
+
Float :value_as_number
|
155
|
+
String :value_as_string, :size=>60
|
156
|
+
Bignum :value_as_concept_id
|
157
|
+
Bignum :unit_concept_id
|
158
|
+
Float :range_low
|
159
|
+
Float :range_high
|
160
|
+
Bignum :observation_type_concept_id, :null=>false
|
161
|
+
Bignum :associated_provider_id
|
162
|
+
Bignum :visit_occurrence_id
|
163
|
+
Bignum :relevant_condition_concept_id
|
164
|
+
String :observation_source_value, :size=>50
|
165
|
+
String :units_source_value, :size=>50
|
166
|
+
|
167
|
+
primary_key [:observation_id]
|
168
|
+
end
|
169
|
+
|
170
|
+
create_table(:observation_period, :ignore_index_errors=>true) do
|
171
|
+
Bignum :observation_period_id, :null=>false
|
172
|
+
foreign_key :person_id, :person, :type=>Bignum, :null=>false, :key=>[:person_id]
|
173
|
+
Date :observation_period_start_date, :null=>false
|
174
|
+
Date :observation_period_end_date, :null=>false
|
175
|
+
Date :prev_ds_period_end_date
|
176
|
+
|
177
|
+
primary_key [:observation_period_id]
|
178
|
+
end
|
179
|
+
|
180
|
+
create_table(:payer_plan_period, :ignore_index_errors=>true) do
|
181
|
+
Bignum :payer_plan_period_id, :null=>false
|
182
|
+
foreign_key :person_id, :person, :type=>Bignum, :null=>false, :key=>[:person_id]
|
183
|
+
Date :payer_plan_period_start_date, :null=>false
|
184
|
+
Date :payer_plan_period_end_date, :null=>false
|
185
|
+
String :payer_source_value, :size=>50
|
186
|
+
String :plan_source_value, :size=>50
|
187
|
+
String :family_source_value, :size=>50
|
188
|
+
Date :prev_ds_period_end_date
|
189
|
+
|
190
|
+
primary_key [:payer_plan_period_id]
|
191
|
+
end
|
192
|
+
|
193
|
+
create_table(:procedure_occurrence, :ignore_index_errors=>true) do
|
194
|
+
Bignum :procedure_occurrence_id, :null=>false
|
195
|
+
foreign_key :person_id, :person, :type=>Bignum, :null=>false, :key=>[:person_id]
|
196
|
+
Bignum :procedure_concept_id, :null=>false
|
197
|
+
Date :procedure_date, :null=>false
|
198
|
+
Bignum :procedure_type_concept_id, :null=>false
|
199
|
+
Bignum :associated_provider_id
|
200
|
+
Bignum :visit_occurrence_id
|
201
|
+
Bignum :relevant_condition_concept_id
|
202
|
+
String :procedure_source_value, :size=>50
|
203
|
+
|
204
|
+
primary_key [:procedure_occurrence_id]
|
205
|
+
end
|
206
|
+
|
207
|
+
create_table(:visit_occurrence, :ignore_index_errors=>true) do
|
208
|
+
Bignum :visit_occurrence_id, :null=>false
|
209
|
+
foreign_key :person_id, :person, :type=>Bignum, :null=>false, :key=>[:person_id]
|
210
|
+
Date :visit_start_date, :null=>false
|
211
|
+
Date :visit_end_date, :null=>false
|
212
|
+
Bignum :place_of_service_concept_id, :null=>false
|
213
|
+
Bignum :care_site_id
|
214
|
+
String :place_of_service_source_value, :size=>50
|
215
|
+
|
216
|
+
primary_key [:visit_occurrence_id]
|
217
|
+
end
|
218
|
+
|
219
|
+
create_table(:drug_cost, :ignore_index_errors=>true) do
|
220
|
+
Bignum :drug_cost_id, :null=>false
|
221
|
+
foreign_key :drug_exposure_id, :drug_exposure, :type=>Bignum, :null=>false, :key=>[:drug_exposure_id]
|
222
|
+
Float :paid_copay
|
223
|
+
Float :paid_coinsurance
|
224
|
+
Float :paid_toward_deductible
|
225
|
+
Float :paid_by_payer
|
226
|
+
Float :paid_by_coordination_benefits
|
227
|
+
Float :total_out_of_pocket
|
228
|
+
Float :total_paid
|
229
|
+
Float :ingredient_cost
|
230
|
+
Float :dispensing_fee
|
231
|
+
Float :average_wholesale_price
|
232
|
+
Bignum :payer_plan_period_id
|
233
|
+
|
234
|
+
primary_key [:drug_cost_id]
|
235
|
+
end
|
236
|
+
|
237
|
+
create_table(:procedure_cost, :ignore_index_errors=>true) do
|
238
|
+
Bignum :procedure_cost_id, :null=>false
|
239
|
+
foreign_key :procedure_occurrence_id, :procedure_occurrence, :type=>Bignum, :null=>false, :key=>[:procedure_occurrence_id]
|
240
|
+
Float :paid_copay
|
241
|
+
Float :paid_coinsurance
|
242
|
+
Float :paid_toward_deductible
|
243
|
+
Float :paid_by_payer
|
244
|
+
Float :paid_by_coordination_benefits
|
245
|
+
Float :total_out_of_pocket
|
246
|
+
Float :total_paid
|
247
|
+
Bignum :disease_class_concept_id
|
248
|
+
Bignum :revenue_code_concept_id
|
249
|
+
Bignum :payer_plan_period_id
|
250
|
+
String :disease_class_source_value, :size=>50
|
251
|
+
String :revenue_code_source_value, :size=>50
|
252
|
+
|
253
|
+
primary_key [:procedure_cost_id]
|
254
|
+
end
|
255
|
+
end
|
256
|
+
end
|
@@ -0,0 +1,145 @@
|
|
1
|
+
Sequel.migration do
|
2
|
+
change do
|
3
|
+
alter_table(:care_site) do
|
4
|
+
add_index [:location_id, :organization_id, :place_of_service_source_value], :name=>:care_site_location_id_organization_id_place_of_service_sour_key, :unique=>true, :ignore_add_index_errors=>true
|
5
|
+
add_index [:care_site_id], :name=>:carsit_carsitid, :ignore_add_index_errors=>true
|
6
|
+
add_index [:location_id], :name=>:carsit_locid, :ignore_add_index_errors=>true
|
7
|
+
add_index [:organization_id], :name=>:carsit_orgid, :ignore_add_index_errors=>true
|
8
|
+
add_index [:place_of_service_concept_id], :name=>:carsit_plaofserconid, :ignore_add_index_errors=>true
|
9
|
+
add_index [:location_id, :organization_id, :place_of_service_source_value, :care_site_id], :name=>:idx_care_site_org_sources, :ignore_add_index_errors=>true
|
10
|
+
end
|
11
|
+
|
12
|
+
alter_table(:cohort) do
|
13
|
+
add_index [:cohort_concept_id], :name=>:coh_cohconid, :ignore_add_index_errors=>true
|
14
|
+
add_index [:cohort_id], :name=>:coh_cohid, :ignore_add_index_errors=>true
|
15
|
+
add_index [:subject_id], :name=>:coh_subid, :ignore_add_index_errors=>true
|
16
|
+
end
|
17
|
+
|
18
|
+
alter_table(:location) do
|
19
|
+
add_index [:location_id], :name=>:loc_locid, :ignore_add_index_errors=>true
|
20
|
+
add_index [:zip, :county], :name=>:location_zip_county_key, :unique=>true, :ignore_add_index_errors=>true
|
21
|
+
end
|
22
|
+
|
23
|
+
alter_table(:provider) do
|
24
|
+
add_index [:provider_source_value, :specialty_source_value, :provider_id, :care_site_id], :name=>:idx_provider_lkp, :ignore_add_index_errors=>true
|
25
|
+
add_index [:care_site_id], :name=>:pro_carsitid, :ignore_add_index_errors=>true
|
26
|
+
add_index [:provider_id], :name=>:pro_proid, :ignore_add_index_errors=>true
|
27
|
+
add_index [:specialty_concept_id], :name=>:pro_speconid, :ignore_add_index_errors=>true
|
28
|
+
end
|
29
|
+
|
30
|
+
alter_table(:organization) do
|
31
|
+
add_index [:location_id], :name=>:org_locid, :ignore_add_index_errors=>true
|
32
|
+
add_index [:organization_id], :name=>:org_orgid, :ignore_add_index_errors=>true
|
33
|
+
add_index [:place_of_service_concept_id], :name=>:org_plaofserconid, :ignore_add_index_errors=>true
|
34
|
+
end
|
35
|
+
|
36
|
+
alter_table(:person) do
|
37
|
+
add_index [:care_site_id], :name=>:per_carsitid, :ignore_add_index_errors=>true
|
38
|
+
add_index [:ethnicity_concept_id], :name=>:per_ethconid, :ignore_add_index_errors=>true
|
39
|
+
add_index [:gender_concept_id], :name=>:per_genconid, :ignore_add_index_errors=>true
|
40
|
+
add_index [:location_id], :name=>:per_locid, :ignore_add_index_errors=>true
|
41
|
+
add_index [:person_id], :name=>:per_perid, :ignore_add_index_errors=>true
|
42
|
+
add_index [:provider_id], :name=>:per_proid, :ignore_add_index_errors=>true
|
43
|
+
add_index [:race_concept_id], :name=>:per_racconid, :ignore_add_index_errors=>true
|
44
|
+
end
|
45
|
+
|
46
|
+
alter_table(:condition_era) do
|
47
|
+
add_index [:condition_concept_id], :name=>:conera_conconid, :ignore_add_index_errors=>true
|
48
|
+
add_index [:condition_era_id], :name=>:conera_coneraid, :ignore_add_index_errors=>true
|
49
|
+
add_index [:condition_type_concept_id], :name=>:conera_contypconid, :ignore_add_index_errors=>true
|
50
|
+
add_index [:person_id], :name=>:conera_perid, :ignore_add_index_errors=>true
|
51
|
+
end
|
52
|
+
|
53
|
+
alter_table(:condition_occurrence) do
|
54
|
+
add_index [:condition_concept_id], :name=>:cci, :ignore_add_index_errors=>true
|
55
|
+
add_index [:associated_provider_id], :name=>:conocc_assproid, :ignore_add_index_errors=>true
|
56
|
+
add_index [:condition_concept_id], :name=>:conocc_conconid, :ignore_add_index_errors=>true
|
57
|
+
add_index [:condition_occurrence_id], :name=>:conocc_conoccid, :ignore_add_index_errors=>true
|
58
|
+
add_index [:condition_source_value], :name=>:conocc_consouval, :ignore_add_index_errors=>true
|
59
|
+
add_index [:condition_type_concept_id], :name=>:conocc_contypconid, :ignore_add_index_errors=>true
|
60
|
+
add_index [:person_id], :name=>:conocc_perid, :ignore_add_index_errors=>true
|
61
|
+
add_index [:visit_occurrence_id], :name=>:conocc_visoccid, :ignore_add_index_errors=>true
|
62
|
+
add_index [:visit_occurrence_id], :name=>:voi, :ignore_add_index_errors=>true
|
63
|
+
end
|
64
|
+
|
65
|
+
alter_table(:death) do
|
66
|
+
add_index [:cause_of_death_concept_id], :name=>:dea_cauofdeaconid, :ignore_add_index_errors=>true
|
67
|
+
add_index [:death_type_concept_id], :name=>:dea_deatypconid, :ignore_add_index_errors=>true
|
68
|
+
add_index [:person_id], :name=>:dea_perid, :ignore_add_index_errors=>true
|
69
|
+
end
|
70
|
+
|
71
|
+
alter_table(:drug_era) do
|
72
|
+
add_index [:drug_concept_id], :name=>:druera_druconid, :ignore_add_index_errors=>true
|
73
|
+
add_index [:drug_era_id], :name=>:druera_drueraid, :ignore_add_index_errors=>true
|
74
|
+
add_index [:drug_type_concept_id], :name=>:druera_drutypconid, :ignore_add_index_errors=>true
|
75
|
+
add_index [:person_id], :name=>:druera_perid, :ignore_add_index_errors=>true
|
76
|
+
end
|
77
|
+
|
78
|
+
alter_table(:drug_exposure) do
|
79
|
+
add_index [:drug_concept_id], :name=>:druexp_druconid, :ignore_add_index_errors=>true
|
80
|
+
add_index [:drug_exposure_id], :name=>:druexp_druexpid, :ignore_add_index_errors=>true
|
81
|
+
add_index [:drug_type_concept_id], :name=>:druexp_drutypconid, :ignore_add_index_errors=>true
|
82
|
+
add_index [:person_id], :name=>:druexp_perid, :ignore_add_index_errors=>true
|
83
|
+
add_index [:prescribing_provider_id], :name=>:druexp_preproid, :ignore_add_index_errors=>true
|
84
|
+
add_index [:relevant_condition_concept_id], :name=>:druexp_relconconid, :ignore_add_index_errors=>true
|
85
|
+
add_index [:visit_occurrence_id], :name=>:druexp_visoccid, :ignore_add_index_errors=>true
|
86
|
+
end
|
87
|
+
|
88
|
+
alter_table(:observation) do
|
89
|
+
add_index [:associated_provider_id], :name=>:obs_assproid, :ignore_add_index_errors=>true
|
90
|
+
add_index [:observation_concept_id], :name=>:obs_obsconid, :ignore_add_index_errors=>true
|
91
|
+
add_index [:observation_id], :name=>:obs_obsid, :ignore_add_index_errors=>true
|
92
|
+
add_index [:observation_type_concept_id], :name=>:obs_obstypconid, :ignore_add_index_errors=>true
|
93
|
+
add_index [:person_id], :name=>:obs_perid, :ignore_add_index_errors=>true
|
94
|
+
add_index [:relevant_condition_concept_id], :name=>:obs_relconconid, :ignore_add_index_errors=>true
|
95
|
+
add_index [:unit_concept_id], :name=>:obs_uniconid, :ignore_add_index_errors=>true
|
96
|
+
add_index [:value_as_concept_id], :name=>:obs_valasconid, :ignore_add_index_errors=>true
|
97
|
+
add_index [:visit_occurrence_id], :name=>:obs_visoccid, :ignore_add_index_errors=>true
|
98
|
+
end
|
99
|
+
|
100
|
+
alter_table(:observation_period) do
|
101
|
+
add_index [:person_id, :observation_period_start_date, :observation_period_end_date], :name=>:idx_observation_period_lkp, :ignore_add_index_errors=>true
|
102
|
+
add_index [:observation_period_id], :name=>:obsper_obsperid, :ignore_add_index_errors=>true
|
103
|
+
add_index [:person_id], :name=>:obsper_perid, :ignore_add_index_errors=>true
|
104
|
+
end
|
105
|
+
|
106
|
+
alter_table(:payer_plan_period) do
|
107
|
+
add_index [:person_id, :plan_source_value, :payer_plan_period_start_date, :payer_plan_period_end_date], :name=>:idx_payer_plan_period_lkp, :ignore_add_index_errors=>true
|
108
|
+
add_index [:payer_plan_period_id], :name=>:payplaper_payplaperid, :ignore_add_index_errors=>true
|
109
|
+
add_index [:person_id], :name=>:payplaper_perid, :ignore_add_index_errors=>true
|
110
|
+
end
|
111
|
+
|
112
|
+
alter_table(:procedure_occurrence) do
|
113
|
+
add_index [:associated_provider_id], :name=>:proocc_assproid, :ignore_add_index_errors=>true
|
114
|
+
add_index [:person_id], :name=>:proocc_perid, :ignore_add_index_errors=>true
|
115
|
+
add_index [:procedure_concept_id], :name=>:proocc_proconid, :ignore_add_index_errors=>true
|
116
|
+
add_index [:procedure_occurrence_id], :name=>:proocc_prooccid, :ignore_add_index_errors=>true
|
117
|
+
add_index [:procedure_source_value], :name=>:proocc_prosouval, :ignore_add_index_errors=>true
|
118
|
+
add_index [:procedure_type_concept_id], :name=>:proocc_protypconid, :ignore_add_index_errors=>true
|
119
|
+
add_index [:relevant_condition_concept_id], :name=>:proocc_relconconid, :ignore_add_index_errors=>true
|
120
|
+
add_index [:visit_occurrence_id], :name=>:proocc_visoccid, :ignore_add_index_errors=>true
|
121
|
+
end
|
122
|
+
|
123
|
+
alter_table(:visit_occurrence) do
|
124
|
+
add_index [:person_id, :visit_start_date, :place_of_service_concept_id], :name=>:visit_occurrence_person_id_visit_start_date_place_of_servic_key, :ignore_add_index_errors=>true
|
125
|
+
add_index [:care_site_id], :name=>:visocc_carsitid, :ignore_add_index_errors=>true
|
126
|
+
add_index [:person_id], :name=>:visocc_perid, :ignore_add_index_errors=>true
|
127
|
+
add_index [:place_of_service_concept_id], :name=>:visocc_plaofserconid, :ignore_add_index_errors=>true
|
128
|
+
add_index [:visit_occurrence_id], :name=>:visocc_visoccid, :ignore_add_index_errors=>true
|
129
|
+
end
|
130
|
+
|
131
|
+
alter_table(:drug_cost) do
|
132
|
+
add_index [:drug_cost_id], :name=>:drucos_drucosid, :ignore_add_index_errors=>true
|
133
|
+
add_index [:drug_exposure_id], :name=>:drucos_druexpid, :ignore_add_index_errors=>true
|
134
|
+
add_index [:payer_plan_period_id], :name=>:drucos_payplaperid, :ignore_add_index_errors=>true
|
135
|
+
end
|
136
|
+
|
137
|
+
alter_table(:procedure_cost) do
|
138
|
+
add_index [:disease_class_concept_id], :name=>:procos_disclaconid, :ignore_add_index_errors=>true
|
139
|
+
add_index [:payer_plan_period_id], :name=>:procos_payplaperid, :ignore_add_index_errors=>true
|
140
|
+
add_index [:procedure_cost_id], :name=>:procos_procosid, :ignore_add_index_errors=>true
|
141
|
+
add_index [:procedure_occurrence_id], :name=>:procos_prooccid, :ignore_add_index_errors=>true
|
142
|
+
add_index [:revenue_code_concept_id], :name=>:procos_revcodconid, :ignore_add_index_errors=>true
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
Sequel.migration do
|
2
|
+
change do
|
3
|
+
create_table(:concept) do
|
4
|
+
Bignum :concept_id, :null=>false
|
5
|
+
String :concept_name, :null=>false
|
6
|
+
BigDecimal :concept_level, :null=>false
|
7
|
+
String :concept_class, :null=>false
|
8
|
+
Bignum :vocabulary_id, :null=>false
|
9
|
+
String :concept_code, :null=>false
|
10
|
+
Date :valid_start_date, :null=>false
|
11
|
+
Date :valid_end_date, :null=>false
|
12
|
+
String :invalid_reason, :size=>1, :fixed=>true
|
13
|
+
|
14
|
+
primary_key [:concept_id]
|
15
|
+
end
|
16
|
+
|
17
|
+
create_table(:concept_ancestor) do
|
18
|
+
Bignum :ancestor_concept_id, :null=>false
|
19
|
+
Bignum :descendant_concept_id, :null=>false
|
20
|
+
BigDecimal :min_levels_of_separation
|
21
|
+
BigDecimal :max_levels_of_separation
|
22
|
+
|
23
|
+
primary_key [:ancestor_concept_id, :descendant_concept_id]
|
24
|
+
end
|
25
|
+
|
26
|
+
create_table(:concept_relationship) do
|
27
|
+
Bignum :concept_id_1, :null=>false
|
28
|
+
Bignum :concept_id_2, :null=>false
|
29
|
+
Bignum :relationship_id, :null=>false
|
30
|
+
Date :valid_start_date, :null=>false
|
31
|
+
Date :valid_end_date, :null=>false
|
32
|
+
String :invalid_reason, :size=>1, :fixed=>true
|
33
|
+
|
34
|
+
primary_key [:concept_id_1, :concept_id_2, :relationship_id]
|
35
|
+
end
|
36
|
+
|
37
|
+
create_table(:concept_synonym) do
|
38
|
+
Bignum :concept_synonym_id, :null=>false
|
39
|
+
Bignum :concept_id, :null=>false
|
40
|
+
String :concept_synonym_name, :null=>false
|
41
|
+
|
42
|
+
primary_key [:concept_synonym_id]
|
43
|
+
end
|
44
|
+
|
45
|
+
create_table(:drug_approval) do
|
46
|
+
Bignum :ingredient_concept_id, :null => false
|
47
|
+
Date :approval_date, :null => false
|
48
|
+
String :approved_by, :null => false
|
49
|
+
end
|
50
|
+
|
51
|
+
create_table(:drug_strength) do
|
52
|
+
Bignum :drug_concept_id, :null => false
|
53
|
+
Bignum :ingredient_concept_id, :null => false
|
54
|
+
BigDecimal :amount_value
|
55
|
+
String :amount_unit
|
56
|
+
BigDecimal :concentration_value
|
57
|
+
String :concentration_enum_unit
|
58
|
+
String :concentration_denom_unit
|
59
|
+
Date :valid_start_date, :null => false
|
60
|
+
Date :valid_end_date, :null => false
|
61
|
+
String :invalid_reason
|
62
|
+
end
|
63
|
+
|
64
|
+
create_table(:relationship) do
|
65
|
+
Bignum :relationship_id, :null=>false
|
66
|
+
String :relationship_name, :null=>false
|
67
|
+
String :is_hierarchical, :size=>1, :fixed=>true
|
68
|
+
String :defines_ancestry, :size=>1, :fixed=>true
|
69
|
+
Bignum :reverse_relationship
|
70
|
+
|
71
|
+
primary_key [:relationship_id]
|
72
|
+
end
|
73
|
+
|
74
|
+
create_table(:source_to_concept_map) do
|
75
|
+
String :source_code, :null=>false
|
76
|
+
Bignum :source_vocabulary_id, :null=>false
|
77
|
+
String :source_code_description
|
78
|
+
Bignum :target_concept_id, :null=>false
|
79
|
+
Bignum :target_vocabulary_id, :null=>false
|
80
|
+
String :mapping_type
|
81
|
+
String :primary_map, :size=>1, :fixed=>true
|
82
|
+
Date :valid_start_date, :null=>false
|
83
|
+
Date :valid_end_date, :null=>false
|
84
|
+
String :invalid_reason, :size=>1, :fixed=>true
|
85
|
+
|
86
|
+
primary_key [:source_code, :source_vocabulary_id, :target_concept_id, :valid_end_date]
|
87
|
+
end
|
88
|
+
|
89
|
+
create_table(:vocabulary) do
|
90
|
+
Bignum :vocabulary_id, :null=>false
|
91
|
+
String :vocabulary_name, :null=>false
|
92
|
+
|
93
|
+
primary_key [:vocabulary_id]
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
|
2
|
+
Sequel.migration do
|
3
|
+
change do
|
4
|
+
puts "Adding indexes"
|
5
|
+
def do_index(*args)
|
6
|
+
puts args.inspect
|
7
|
+
add_index(*args)
|
8
|
+
rescue
|
9
|
+
puts $!.message
|
10
|
+
#nothing
|
11
|
+
end
|
12
|
+
do_index :concept, [:concept_code], name: "vocabulary_concept_concept_code_index"
|
13
|
+
do_index :concept, [:concept_id], name: "con_conid"
|
14
|
+
do_index :concept, [:vocabulary_id], name: "con_vocid"
|
15
|
+
do_index :concept_ancestor, [:ancestor_concept_id], name: "conanc_ancconid"
|
16
|
+
do_index :concept_ancestor, [:descendant_concept_id], name: "conanc_desconid"
|
17
|
+
do_index :concept_relationship, [:relationship_id], name: "conrel_relid"
|
18
|
+
do_index :relationship, [:relationship_id], name: "rel_relid"
|
19
|
+
do_index :source_to_concept_map, [:source_code, :source_vocabulary_id], name: "soutoconmap_soucod_souvocid"
|
20
|
+
do_index :source_to_concept_map, [:source_vocabulary_id], name: "soutoconmap_souvocid"
|
21
|
+
do_index :source_to_concept_map, [:target_concept_id], name: "soutoconmap_tarconid"
|
22
|
+
do_index :source_to_concept_map, [:target_vocabulary_id], name: "soutoconmap_tarvocid"
|
23
|
+
end
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,122 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: loadmop
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ryan Duryea
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-07-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.3'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: sequelizer
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: thor
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.19'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.19'
|
69
|
+
description: loadmop assits in loading OMOP Vocabulary files and OMOP CDMv4-compatible
|
70
|
+
CSV files into your database
|
71
|
+
email:
|
72
|
+
- aguynamedryan@gmail.com
|
73
|
+
executables:
|
74
|
+
- loadmop
|
75
|
+
extensions: []
|
76
|
+
extra_rdoc_files: []
|
77
|
+
files:
|
78
|
+
- ".gitignore"
|
79
|
+
- CHANGELOG.md
|
80
|
+
- Gemfile
|
81
|
+
- LICENSE.txt
|
82
|
+
- README.md
|
83
|
+
- Rakefile
|
84
|
+
- bin/loadmop
|
85
|
+
- config/database.yml.example
|
86
|
+
- lib/loadmop.rb
|
87
|
+
- lib/loadmop/cdmv4_loader.rb
|
88
|
+
- lib/loadmop/cli.rb
|
89
|
+
- lib/loadmop/loader.rb
|
90
|
+
- lib/loadmop/version.rb
|
91
|
+
- lib/loadmop/vocab_loader.rb
|
92
|
+
- loadmop.gemspec
|
93
|
+
- schemas/cdmv4/001_tables.rb
|
94
|
+
- schemas/cdmv4/002_indexes.rb
|
95
|
+
- schemas/vocabulary/001_tables.rb
|
96
|
+
- schemas/vocabulary/002_indexes.rb
|
97
|
+
homepage: https://github.com/outcomesinsights/loadmop
|
98
|
+
licenses:
|
99
|
+
- MIT
|
100
|
+
metadata: {}
|
101
|
+
post_install_message:
|
102
|
+
rdoc_options: []
|
103
|
+
require_paths:
|
104
|
+
- lib
|
105
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0'
|
115
|
+
requirements: []
|
116
|
+
rubyforge_project:
|
117
|
+
rubygems_version: 2.2.2
|
118
|
+
signing_key:
|
119
|
+
specification_version: 4
|
120
|
+
summary: Ruby-based script to load OMOP Vocabulary/CDMv4 data into a database
|
121
|
+
test_files: []
|
122
|
+
has_rdoc:
|