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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5b0a7541767818581d2b1c1713ea142c209b5760
4
- data.tar.gz: b0a3311519d30bf8ffe9a2c1bc32f0844f2c0252
3
+ metadata.gz: 05a9df0e23a9635d9ecf4bfe4c509edd18b31929
4
+ data.tar.gz: 21589cdb748eb1c7a890483aa646d18b88342da2
5
5
  SHA512:
6
- metadata.gz: 6b5c6e7a8527d09b661c760e26d60d50ed3fe6e81dc7b219a0b6afc81c1fb74109e439cd9c83443ca81128a56663e0fd320f42428fb3646c2c2fcab2ac0b8baf
7
- data.tar.gz: b7c6bfdfa2204a627d555f2745eb5d47d824ff7a40d0922fb7500b5b613b25312d0f992531d21b6d00b096f721c49108fcc6bd0f08e017a67ff1aff11abe53b6
6
+ metadata.gz: 78ed294dce472124d213558925fc35a3522c161e9b41d208e13de45963cccbf935f61c778e341d700ba09fbc34623f46894d409be28cc99bebfb6c87b49075fc
7
+ data.tar.gz: 4af2380087759f096ebfe3d0fcd70c4994976e8a248c860841c7176db6a218dc399f4cfb1d7f2501cf215dd15f56957bb5d9b4cfef8ffcf4ff6c222830f624c4
@@ -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
@@ -1,3 +1,3 @@
1
1
  module ProviderTaxonomy
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
@@ -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 import: :environment do
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.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