Skip to content

Commit

Permalink
use pure ruby ccr importer in HDS
Browse files Browse the repository at this point in the history
  • Loading branch information
ssayer committed Feb 15, 2012
1 parent f719e96 commit 44d05e3
Show file tree
Hide file tree
Showing 11 changed files with 759 additions and 94 deletions.
7 changes: 4 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ gem 'rails', '3.1.0'
# locked to 1.3.3 to resolve annoying warning 'already initialized constant WFKV_'
gem 'rack' , '1.3.3'

#gem 'quality-measure-engine', :path => '../quality-measure-engine/'
gem 'quality-measure-engine', :git => 'http://github.com/pophealth/quality-measure-engine.git', :branch => 'develop'
gem 'health-data-standards', :git => 'https://github.com/projectcypress/health-data-standards.git', :branch => 'develop'

gem 'quality-measure-engine', :git => 'http://github.com/ssayer/quality-measure-engine.git', :branch => 'master'
gem 'health-data-standards', :git => 'https://github.com/ssayer/health-data-standards.git', :branch => 'master'

gem 'nokogiri'
gem 'rubyzip'

Expand Down
82 changes: 38 additions & 44 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
GIT
remote: http://github.com/pophealth/quality-measure-engine.git
revision: 578e6a70c5d6e80417457855b831c3423cd9e837
branch: develop
remote: http://github.com/ssayer/quality-measure-engine.git
revision: bc27940b1c9946f3cf70004ad9a54eed80c17483
branch: master
specs:
quality-measure-engine (1.1.0)
quality-measure-engine (1.1.1)
mongo (~> 1.3)
nokogiri (~> 1.4.4)
resque (~> 1.15.0)
resque-status (~> 0.2.3)
rubyzip (~> 0.9.4)

GIT
remote: https://github.com/projectcypress/health-data-standards.git
revision: 849fa7b8fdf2e1cf9f45ea933dc226d1e4ef7ef6
branch: develop
remote: https://github.com/ssayer/health-data-standards.git
revision: ba8ffa96923c5e531c64a7c1f69ef5c51038516b
branch: master
specs:
health-data-standards (0.5.0)
health-data-standards (0.7.0)
builder (~> 3.0.0)
erubis (~> 2.6)
mongoid (~> 2.3.3)
Expand Down Expand Up @@ -54,37 +54,38 @@ GEM
activesupport (= 3.1.0)
activesupport (3.1.0)
multi_json (~> 1.0)
ansi (1.4.1)
ansi (1.4.2)
arel (2.2.1)
bcrypt-ruby (3.0.1)
bson (1.3.1)
bson_ext (1.3.1)
builder (3.0.0)
cancan (1.6.7)
coderay (0.9.8)
coderay (1.0.5)
coffee-rails (3.1.1)
coffee-script (>= 2.2.0)
railties (~> 3.1.0)
coffee-script (2.2.0)
coffee-script-source
execjs
coffee-script-source (1.1.3)
coffee-script-source (1.2.0)
configatron (2.9.0)
yamler (>= 0.1.0)
cover_me (1.2.0)
configatron
hashie
devise (1.5.2)
devise (2.0.2)
bcrypt-ruby (~> 3.0)
orm_adapter (~> 0.0.3)
railties (~> 3.1)
warden (~> 1.1)
erubis (2.7.0)
execjs (1.2.12)
execjs (1.3.0)
multi_json (~> 1.0)
factory_girl (2.3.2)
activesupport
foreman (0.27.0)
term-ansicolor (~> 1.0.5)
factory_girl (2.5.2)
activesupport (>= 2.3.9)
foreman (0.39.0)
term-ansicolor (~> 1.0.7)
thor (>= 0.13.6)
formtastic (2.0.2)
rails (~> 3.0)
Expand All @@ -99,7 +100,7 @@ GEM
actionpack (>= 3.0.0)
activesupport (>= 3.0.0)
railties (>= 3.0.0)
kgio (2.7.0)
kgio (2.7.2)
libv8 (3.3.10.4)
macaddr (1.5.0)
systemu (>= 2.4.0)
Expand All @@ -108,11 +109,10 @@ GEM
mime-types (~> 1.16)
treetop (~> 1.4.8)
metaclass (0.0.1)
method_source (0.6.7)
ruby_parser (>= 2.3.1)
method_source (0.7.0)
mime-types (1.17.2)
minitest (2.9.1)
mocha (0.10.0)
minitest (2.11.2)
mocha (0.10.4)
metaclass (~> 0.0.1)
mongo (1.3.1)
bson (>= 1.3.1)
Expand All @@ -122,13 +122,12 @@ GEM
tzinfo (~> 0.3.22)
multi_json (1.0.4)
nokogiri (1.4.7)
orm_adapter (0.0.5)
orm_adapter (0.0.6)
polyglot (0.3.3)
pry (0.9.7.4)
coderay (~> 0.9.8)
method_source (~> 0.6.7)
ruby_parser (>= 2.3.1)
slop (~> 2.1.0)
pry (0.9.8.2)
coderay (~> 1.0.5)
method_source (~> 0.7)
slop (>= 2.4.4, < 3)
rack (1.3.3)
rack-cache (1.0.3)
rack (>= 0.4)
Expand Down Expand Up @@ -174,27 +173,22 @@ GEM
redisk (>= 0.2.1)
resque (>= 1.3.1)
uuid (>= 2.0.2)
ruby_parser (2.3.1)
sexp_processor (~> 3.0)
rubyzip (0.9.5)
sass (3.1.11)
rubyzip (0.9.6.1)
sass (3.1.15)
sass-rails (3.1.5)
actionpack (~> 3.1.0)
railties (~> 3.1.0)
sass (~> 3.1.10)
tilt (~> 1.3.2)
sexp_processor (3.0.9)
sinatra (1.3.0)
rack (~> 1.3)
rack-protection (~> 1.1)
tilt (~> 1.3)
slop (2.1.0)
slop (2.4.4)
sprockets (2.0.3)
hike (~> 1.2)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
tilt (~> 1.1, != 1.3.0)
tilt (~> 1.1, != 1.3.0)
systemu (2.4.2)
term-ansicolor (1.0.7)
therubyracer (0.9.9)
Expand All @@ -204,23 +198,23 @@ GEM
treetop (1.4.10)
polyglot
polyglot (>= 0.3.1)
turn (0.8.3)
turn (0.9.2)
ansi
tzinfo (0.3.31)
uglifier (1.2.0)
uglifier (1.2.3)
execjs (>= 0.3.0)
multi_json (>= 1.0.2)
unicorn (4.1.1)
kgio (~> 2.4)
unicorn (4.2.0)
kgio (~> 2.6)
rack
raindrops (~> 0.6)
uuid (2.3.4)
raindrops (~> 0.7)
uuid (2.3.5)
macaddr (~> 1.0)
vegas (0.1.8)
vegas (0.1.11)
rack (>= 1.0.0)
warden (1.1.0)
rack (>= 1.0)
will_paginate (3.0.2)
will_paginate (3.0.3)
yamler (0.1.0)

PLATFORMS
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/measures_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ def setup_filters
else

if can?(:read, :providers)
@providers = Provider.alphabetical.page(@page).per(20)
@providers = Provider.page(@page).per(20).alphabetical
if APP_CONFIG['disable_provider_filters']
@teams = Team.alphabetical
@page = params[:page]
Expand Down
6 changes: 5 additions & 1 deletion config/environment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,9 @@
# Initialize the rails application
PopHealth::Application.initialize!

Provider.send(:include, Kaminari::MongoidExtension::Document)
Record.send(:include, Kaminari::MongoidExtension::Document)
require_relative '../lib/hds/record.rb'

require_relative '../lib/hds/record.rb'
require_relative '../lib/hds/provider.rb'
require_relative '../lib/hds/provider_performance.rb'
21 changes: 0 additions & 21 deletions lib/ccr_importer.rb

This file was deleted.

6 changes: 1 addition & 5 deletions app/models/provider.rb → lib/hds/provider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,5 @@ def merge_provider!(provider)
merge_provider(provider)
save!
end

def records(effective_date=nil)
Record.by_provider(self, effective_date)
end


end
File renamed without changes.
8 changes: 1 addition & 7 deletions lib/hds/record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,11 @@ class Record
embeds_many section, as: :entry_list, class_name: "Entry"
end

embeds_many :provider_performances


scope :alphabetical, order_by([:last, :asc], [:first, :asc])
scope :with_provider, where(:provider_performances.ne => nil).or(:provider_proformances.ne => [])
scope :without_provider, any_of({provider_performances: nil}, {provider_performances: []})
scope :by_provider, ->(prov, effective_date) { (effective_date) ? where(provider_queries(prov.id, effective_date)) : where('provider_performances.provider_id'=>prov.id) }
scope :by_patient_id, ->(id) { where(:medical_record_number => id) }
scope :provider_performance_between, ->(effective_date) { where("provider_performances.start_date" => {"$lt" => effective_date}).and('$or' => [{'provider_performances.end_date' => nil}, 'provider_performances.end_date' => {'$gt' => effective_date}]) }

def self.update_or_create(data)
Expand All @@ -32,10 +30,6 @@ def self.update_or_create(data)
end
end

def providers
provider_performances.map {|pp| pp.provider }
end

def language_names
lang_codes = languages.map { |l| l.gsub(/\-[A-Z]*$/, "") }
Language.ordered.by_code(lang_codes).map(&:name)
Expand Down
17 changes: 7 additions & 10 deletions lib/record_importer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,18 @@ def run

def self.import(xml_data, provider_map = {})
doc = Nokogiri::XML(xml_data)
doc.root.add_namespace_definition('cda', 'urn:hl7-org:v3')

providers = []
root_element_name = doc.root.name

if root_element_name == 'ClinicalDocument'
doc.root.add_namespace_definition('cda', 'urn:hl7-org:v3')
patient_data = HealthDataStandards::Import::C32::PatientImporter.instance.parse_c32(doc)
providers = QME::Importer::ProviderImporter.instance.extract_providers(doc)
providers = HealthDataStandards::Import::C32::ProviderImporter.instance.extract_providers(doc)
elsif root_element_name == 'ContinuityOfCareRecord'
if RUBY_PLATFORM =~ /java/
ccr_importer = CCRImporter.instance
patient_raw_json = ccr_importer.create_patient(xml_file)
patient_data = JSON.parse(patient_raw_json)
else
return {status: 'error', message: 'CCR Support is currently disabled', status_code: 500}
end
doc.root.add_namespace_definition('ccr', 'urn:astm-org:CCR')
patient_data = HealthDataStandards::Import::CCR::PatientImporter.instance.parse_ccr(doc)
providers = HealthDataStandards::Import::CCR::ProviderImporter.instance.extract_providers(doc)
else
return {status: 'error', message: 'Unknown XML Format', status_code: 400}
end
Expand Down
Loading

0 comments on commit 44d05e3

Please sign in to comment.