Class: HealthDataStandards::CQM::PatientCache

Inherits:
Object
  • Object
show all
Includes:
Mongoid::Document, Mongoid::Timestamps
Defined in:
lib/health-data-standards/models/cqm/patient_cache.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.smoking_gun_rational(hqmf_id, sub_ids = nil, filter = {}) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/health-data-standards/models/cqm/patient_cache.rb', line 15

def self.smoking_gun_rational(hqmf_id,sub_ids=nil, filter ={})

	match = {"value.IPP" => {"$gt" => 0},
				   "value.measure_id" => hqmf_id
	}.merge filter

	if sub_ids
		match["value.sub_id"] = {"$in" => sub_ids}
	end

	group = {"$group" => {"_id" => "$value.medical_record_id", "rational" => {"$push"=> "$value.rationale"}}}
  aggregate = self.mongo_session.command(:aggregate => 'patient_cache', :pipeline => [{"$match" =>match},group])

  merged = {}
  aggregate["result"].each do |agg|
  	mrn = agg["_id"]
  	rational = {}
  	merged[mrn] = rational
    agg["rational"].each do |r|
  		rational.merge! r 
  	end
  end

  merged
end

Instance Method Details

#recordObject



11
12
13
# File 'lib/health-data-standards/models/cqm/patient_cache.rb', line 11

def record
	Record.where(:medical_record_number => value['medical_record_id'], :test_id => value["test_id"]).first
end