provider_taxonomy 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/taxonomy_item.rb +27 -0
- data/db/institution_types.csv +29 -0
- data/lib/provider_taxonomy/version.rb +1 -1
- data/lib/tasks/import.rake +122 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 05a9df0e23a9635d9ecf4bfe4c509edd18b31929
|
4
|
+
data.tar.gz: 21589cdb748eb1c7a890483aa646d18b88342da2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 78ed294dce472124d213558925fc35a3522c161e9b41d208e13de45963cccbf935f61c778e341d700ba09fbc34623f46894d409be28cc99bebfb6c87b49075fc
|
7
|
+
data.tar.gz: 4af2380087759f096ebfe3d0fcd70c4994976e8a248c860841c7176db6a218dc399f4cfb1d7f2501cf215dd15f56957bb5d9b4cfef8ffcf4ff6c222830f624c4
|
data/app/models/taxonomy_item.rb
CHANGED
@@ -1,3 +1,30 @@
|
|
1
1
|
class TaxonomyItem < ActiveRecord::Base
|
2
2
|
belongs_to :parent, foreign_key: :parent_id, class_name: TaxonomyItem, required: false
|
3
|
+
scope :categorized, -> { where.not(category: nil) }
|
4
|
+
DEPTHS = {
|
5
|
+
provider_types: 1,
|
6
|
+
specialties: 2,
|
7
|
+
sub_specialties: 3
|
8
|
+
}.freeze
|
9
|
+
|
10
|
+
class << self
|
11
|
+
def provider_types
|
12
|
+
Specialty.where(depth: DEPTHS[:provider_types])
|
13
|
+
end
|
14
|
+
|
15
|
+
def specialties
|
16
|
+
Specialty.where(depth: DEPTHS[:specialties])
|
17
|
+
end
|
18
|
+
|
19
|
+
def sub_specialties
|
20
|
+
Specialty.where(depth: DEPTHS[:sub_specialties])
|
21
|
+
end
|
22
|
+
|
23
|
+
def search_by_name(query)
|
24
|
+
sql = Specialty.all
|
25
|
+
sql = sql.where('name ILIKE ?', "%#{query}%") if query.present?
|
26
|
+
|
27
|
+
sql
|
28
|
+
end
|
29
|
+
end
|
3
30
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
Name,Category,Sub-Category
|
2
|
+
Community Mental Health Center,institution,non-hospital
|
3
|
+
Comprehensive Outpatient Rehabilitation Facility,institution,non-hospital
|
4
|
+
Critical Access Hospital,institution,non-hospital
|
5
|
+
End-Stage Renal Disease Facility,institution,non-hospital
|
6
|
+
Federally Qualified Health Center,institution,non-hospital
|
7
|
+
Histocompatibility Laboratory,institution,non-hospital
|
8
|
+
Home Health Agency,institution,non-hospital
|
9
|
+
Home Health Agency (Sub-unit),institution,non-hospital
|
10
|
+
Hospice,institution,non-hospital
|
11
|
+
Indian Health Services Facility,institution,non-hospital
|
12
|
+
Organ Procurement Organization,institution,non-hospital
|
13
|
+
Outpatient Physical Therapy/Occupational Therapy/ Speech Pathology Services,institution,non-hospital
|
14
|
+
Religious Non-Medical Health Care Institution,institution,non-hospital
|
15
|
+
Rural Health Clinic,institution,non-hospital
|
16
|
+
Skilled Nursing Facility,institution,non-hospital
|
17
|
+
Other,institution,non-hospital
|
18
|
+
Hospital—General,institution,hospital
|
19
|
+
Hospital—Acute Care,institution,hospital
|
20
|
+
Hospital—Children’s (excluded from PPS),institution,hospital
|
21
|
+
Hospital—Long-Term (excluded from PPS),institution,hospital
|
22
|
+
Hospital—Psychiatric (excluded from PPS),institution,hospital
|
23
|
+
Hospital—Rehabilitation (excluded from PPS),institution,hospital
|
24
|
+
Hospital—Short-Term (General and Specialty),institution,hospital
|
25
|
+
Hospital—Swing-Bed approved,institution,hospital
|
26
|
+
Hospital—Psychiatric Unit,institution,hospital
|
27
|
+
Hospital—Rehabilitation Unit,institution,hospital
|
28
|
+
"Hospital—Specialty Hospital (cardiac, orthopedic, or surgical)",institution,hospital
|
29
|
+
Other,institution,hospital
|
data/lib/tasks/import.rake
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
namespace :provider_taxonomy do
|
2
|
+
desc 'Run all import tasks'
|
3
|
+
task import: [:import_provider_taxonomy, :import_categories, :import_institution_taxonomy] do
|
4
|
+
puts 'Ready to go!'
|
5
|
+
end
|
6
|
+
|
2
7
|
desc 'Import data representing provider specialties taxonomy. Result is db table with parent ids and depth for each entry.'
|
3
|
-
task
|
8
|
+
task import_provider_taxonomy: :environment do
|
4
9
|
require 'csv'
|
5
10
|
require 'open-uri'
|
6
11
|
|
@@ -107,4 +112,120 @@ namespace :provider_taxonomy do
|
|
107
112
|
puts 'Provider taxonomy imported.'
|
108
113
|
FileUtils.rm_rf 'db/provider_taxonomy'
|
109
114
|
end
|
115
|
+
|
116
|
+
desc 'Import provider type specialties categories.'
|
117
|
+
task import_categories: :environment do
|
118
|
+
INDIVIDUAL_SPECIALTIES = [
|
119
|
+
'Allopathic & Osteopathic Physicians',
|
120
|
+
'Behavioral Health & Social Service Providers',
|
121
|
+
'Chiropractic Providers',
|
122
|
+
'Dental Providers',
|
123
|
+
'Dietary & Nutritional Service Providers',
|
124
|
+
'Emergency Medical Service Providers',
|
125
|
+
'Eye and Vision Services Providers',
|
126
|
+
'Nursing Service Providers',
|
127
|
+
'Nursing Service Related Providers',
|
128
|
+
'Other Service Providers',
|
129
|
+
'Pharmacy Service Providers',
|
130
|
+
'Physician Assistants & Advanced Practice Nursing Providers',
|
131
|
+
'Podiatric Medicine & Surgery Service Providers',
|
132
|
+
'Respiratory, Developmental, Rehabilitative and Restorative Service Providers',
|
133
|
+
'Speech, Language and Hearing Service Providers',
|
134
|
+
'Student, Health Care',
|
135
|
+
'Technologists, Technicians & Other Technical Service Providers'
|
136
|
+
].freeze
|
137
|
+
|
138
|
+
GROUP_SPECIALTIES = ['Group'].freeze
|
139
|
+
|
140
|
+
INSTITUTIONAL_SPECIALTIES = [
|
141
|
+
'Agencies',
|
142
|
+
'Ambulatory Health Care Facilities',
|
143
|
+
'Hospital Units',
|
144
|
+
'Hospitals',
|
145
|
+
'Laboratories',
|
146
|
+
'Managed Care Organizations',
|
147
|
+
'Nursing & Custodial Care Facilities',
|
148
|
+
'Other Service Providers',
|
149
|
+
'Residential Treatment Facilities',
|
150
|
+
'Respite Care Facility',
|
151
|
+
'Transportation Services'
|
152
|
+
].freeze
|
153
|
+
|
154
|
+
SUPPLIER_SPECIALTIES = [
|
155
|
+
'Suppliers'
|
156
|
+
].freeze
|
157
|
+
|
158
|
+
if ActiveRecord::Base.connection.table_exists? 'taxonomy_items'
|
159
|
+
|
160
|
+
print "Importing provider type specialty categories\n"
|
161
|
+
provider_types = TaxonomyItem.provider_types
|
162
|
+
|
163
|
+
INDIVIDUAL_SPECIALTIES.each do |specialty|
|
164
|
+
s = TaxonomyItem.find(provider_types.where(name: specialty).first.id)
|
165
|
+
s.update_attributes(category: s.category = 'individual')
|
166
|
+
print "."
|
167
|
+
end
|
168
|
+
|
169
|
+
GROUP_SPECIALTIES.each do |specialty|
|
170
|
+
s = TaxonomyItem.find(provider_types.where(name: specialty).first.id)
|
171
|
+
s.update_attributes(category: s.category = 'group')
|
172
|
+
print "."
|
173
|
+
end
|
174
|
+
|
175
|
+
INSTITUTIONAL_SPECIALTIES.each do |specialty|
|
176
|
+
s = TaxonomyItem.find(provider_types.where(name: specialty).first.id)
|
177
|
+
s.update_attributes(category: s.category = 'institution')
|
178
|
+
print "."
|
179
|
+
end
|
180
|
+
|
181
|
+
SUPPLIER_SPECIALTIES.each do |specialty|
|
182
|
+
s = TaxonomyItem.find(provider_types.where(name: specialty).first.id)
|
183
|
+
s.update_attributes(category: s.category = 'supplier')
|
184
|
+
print "."
|
185
|
+
end
|
186
|
+
|
187
|
+
print "\n"
|
188
|
+
|
189
|
+
else
|
190
|
+
print "The 'taxonomy_items' table does not exist. Be sure to create it first."
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
desc 'Import data representing institution specialties taxonomy. '
|
195
|
+
task import_institution_taxonomy: :environment do
|
196
|
+
require 'csv'
|
197
|
+
|
198
|
+
table = 'taxonomy_items'
|
199
|
+
|
200
|
+
$stdout.sync = true
|
201
|
+
|
202
|
+
if ActiveRecord::Base.connection.table_exists? table
|
203
|
+
|
204
|
+
csv_text = File.read(ProviderTaxonomy::Engine.root + 'db/institution_types.csv')
|
205
|
+
csv = CSV.parse(csv_text, :headers => true)
|
206
|
+
|
207
|
+
existing_institution_types = TaxonomyItem.where(category: 'institution')
|
208
|
+
|
209
|
+
print "Importing institution taxonomy\n"
|
210
|
+
csv.each_with_index do |row, i|
|
211
|
+
|
212
|
+
print "\n" if i % 80 == 0
|
213
|
+
|
214
|
+
if !existing_institution_types.exists?(name: row['Name'], sub_category: row['Sub-Category'])
|
215
|
+
|
216
|
+
# Create this type
|
217
|
+
TaxonomyItem.create!(
|
218
|
+
name: row['Name'],
|
219
|
+
category: row['Category'],
|
220
|
+
sub_category: row['Sub-Category'],
|
221
|
+
).id
|
222
|
+
print "*"
|
223
|
+
end
|
224
|
+
print "."
|
225
|
+
end
|
226
|
+
print "\n"
|
227
|
+
else
|
228
|
+
print "The #{table} table does not exist. Please create it first."
|
229
|
+
end
|
230
|
+
end
|
110
231
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: provider_taxonomy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ClydeDroid
|
@@ -50,6 +50,7 @@ files:
|
|
50
50
|
- README.md
|
51
51
|
- Rakefile
|
52
52
|
- app/models/taxonomy_item.rb
|
53
|
+
- db/institution_types.csv
|
53
54
|
- db/migrate/20160909180325_create_taxonomy_items.rb
|
54
55
|
- lib/provider_taxonomy.rb
|
55
56
|
- lib/provider_taxonomy/engine.rb
|