Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ gem 'jquery-rails'
gem 'jquery-ui-rails'
gem 'rake'


# gem 'quality-measure-engine', :git => 'https://github.com/pophealth/quality-measure-engine.git', :branch => 'master'

# gem 'quality-measure-engine', :path => '../quality-measure-engine'

gem 'quality-measure-engine', '3.1.2'
gem 'health-data-standards', "3.5.3"
#gem 'health-data-standards', "3.5.3"
gem 'health-data-standards',:git => 'https://github.com/ESRogs/health-data-standards.git', :branch => 'master'

# gem 'health-data-standards',:git => 'https://github.com/projectcypress/health-data-standards.git', :branch => 'master'

Expand Down
268 changes: 0 additions & 268 deletions Gemfile.lock

This file was deleted.

87 changes: 71 additions & 16 deletions app/models/calculated_product_test.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

require 'zip/zip'
class CalculatedProductTest < ProductTest

aasm :column => :state do
Expand All @@ -20,6 +20,46 @@ class CalculatedProductTest < ProductTest
#after the test is created generate the population
after_create :gen_pop

def initialize(args = nil)
if args != nil
if args.has_key?("test_zip")
test_zip = args["test_zip"]
@uploaded_patient_xml_strings = get_file_contents_from_zip(test_zip)
# ROGTODO: should the patient strings be passed as part of agrs to super?
measure_ids = get_measure_ids_from_patient_xml_string(@uploaded_patient_xml_strings[0])
@uploaded_patient_xml_strings.each do |ps|
patient_measure_ids = get_measure_ids_from_patient_xml_string(ps)
patient_measure_ids.each { |pmi| raise "Patients have different measure ids!" unless measure_ids.include?(pmi) }
end
# ROGTODO: don't hardcode effective_date
return super({"name"=>args["name"], "product_id"=>args["product_id"], "effective_date"=>"1388534399", "measure_ids"=>measure_ids})
end
end
super(args)
end

def get_file_contents_from_zip(test_zip)
data = test_zip.open.read
content_strings = []
Zip::ZipFile.open(test_zip.path()) do |zipfile|
zipfile.each do |entry|
cs = entry.get_input_stream.read
content_strings.push(cs)
end
end
content_strings
end

def get_measure_ids_from_patient_xml_string(patient_xml_string)
doc = Nokogiri::XML(patient_xml_string)
# ROGTODO: handle other formats?
doc.root.add_namespace_definition('cda', 'urn:hl7-org:v3')
nodes = doc.xpath("/cda:ClinicalDocument/cda:component/cda:structuredBody/cda:component/cda:section/cda:entry/cda:organizer/cda:templateId[@root='2.16.840.1.113883.10.20.24.3.97']")
measure_ids = []
nodes.each { |node| measure_ids << node.next_element["extension"] }
measure_ids
end

def gen_pop
self.generate_population
end
Expand All @@ -31,25 +71,40 @@ def calculate_expected_results
end

def generate_records
min_set = PatientPopulation.min_coverage(self.measure_ids, self.bundle)
p_ids = min_set[:minimal_set]
overflow = min_set[:overflow]
all = p_ids + overflow
randomization_ids = all
while p_ids.length < 5 && overflow.length != 0
if @uploaded_patient_xml_strings != nil
@uploaded_patient_xml_strings.each do |ps|
pr = HealthDataStandards::Import::BulkRecordImporter.import_and_return_unsaved_record(ps)
pr["test_id"] = self.id
pr.save
end
# ROGTODO: need to do the medical_record_assigner part?
else
min_set = PatientPopulation.min_coverage(self.measure_ids, self.bundle)
p_ids = min_set[:minimal_set]
print "minimal ids:\n"
print p_ids.length.to_s() + "\n"
p_ids.each { |pid| print pid + "\n" }
print "\n"
overflow = min_set[:overflow]
print "overflow length: " + overflow.length.to_s() + "\n"
all = p_ids + overflow
randomization_ids = all
while p_ids.length < 5 && overflow.length != 0
p_ids << overflow.sample
end
#randomly pick a number of other patients to give to the vendor
end
#randomly pick a number of other patients to give to the vendor

# do this synchronously because it does not take long
# p_ids = Record.where(:test_id=>nil, :type=>"ep").collect{|p| p.medical_record_number}
pcj = Cypress::PopulationCloneJob.new({'patient_ids' =>p_ids, 'test_id' => self.id, "randomize_names"=> true, "randomization_ids" => randomization_ids})
pcj.perform
# do this synchronously because it does not take long
# p_ids = Record.where(:test_id=>nil, :type=>"ep").collect{|p| p.medical_record_number}
pcj = Cypress::PopulationCloneJob.new({'patient_ids' =>p_ids, 'test_id' => self.id, "randomize_names"=> true, "randomization_ids" => randomization_ids})
pcj.perform

self.records.each do |r|
r.medical_record_assigner = "Cypress" if r.medical_record_assigner.nil?
r.save!
self.records.each do |r|
r.medical_record_assigner = "Cypress" if r.medical_record_assigner.nil?
r.save!
end
end

#now calculate the expected results
self.calculate
end
Expand Down
Loading