quality-measure-engine 2.5.3 → 3.0.0.beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,12 +1,41 @@
1
1
  module QME
2
2
 
3
+ class QualityReportResult
4
+ include Mongoid::Document
5
+ include Mongoid::Timestamps
6
+
7
+ field :population_ids, type: Hash
8
+ field :IPP, type: Integer
9
+ field :DENOM, type: Integer
10
+ field :NUMER, type: Integer
11
+ field :antinumerator, type: Integer
12
+ field :DENEX, type: Integer
13
+ field :DENEXCEP, type: Integer
14
+ field :MSRPOPL, type: Integer
15
+ field :OBSERV, type: Float
16
+ field :supplemental_data, type: Hash
17
+
18
+ embedded_in :quality_report, inverse_of: :result
19
+ end
3
20
  # A class that allows you to create and obtain the results of running a
4
21
  # quality measure against a set of patient records.
5
22
  class QualityReport
6
23
 
7
- include DatabaseAccess
8
- extend DatabaseAccess
9
- determine_connection_information
24
+ include Mongoid::Document
25
+ include Mongoid::Timestamps
26
+ store_in collection: 'query_cache'
27
+
28
+ field :nqf_id, type: String
29
+ field :npi, type: String
30
+ field :calculation_time, type: Time
31
+ field :status, type: Hash, default: {"state" => "unkown", "log" => []}
32
+ field :measure_id, type: String
33
+ field :sub_id, type: String
34
+ field :test_id
35
+ field :effective_date, type: Integer
36
+ field :filters, type: Hash
37
+ embeds_one :result, class_name: "QME::QualityReportResult", inverse_of: :quality_report
38
+
10
39
 
11
40
  POPULATION = 'IPP'
12
41
  DENOMINATOR = 'DENOM'
@@ -24,29 +53,21 @@ module QME
24
53
  POSTAL_CODE = 'POSTAL_CODE'
25
54
  PAYER = 'PAYER'
26
55
 
27
- # Gets rid of all calculated QualityReports by dropping the patient_cache
28
- # and query_cache collections
29
- def self.destroy_all
30
- determine_connection_information
31
- get_db()["query_cache"].drop
32
- get_db()["patient_cache"].drop
33
- end
56
+
34
57
 
35
58
  # Removes the cached results for the patient with the supplied id and
36
59
  # recalculates as necessary
37
60
  def self.update_patient_results(id)
38
- determine_connection_information()
39
-
40
61
  # TODO: need to wait for any outstanding calculations to complete and then prevent
41
62
  # any new ones from starting until we are done.
42
63
 
43
64
  # drop any cached measure result calculations for the modified patient
44
- get_db()["patient_cache"].find('value.medical_record_id' => id).remove_all()
65
+ QME::PatientCache.where('value.medical_record_id' => id).destroy()
45
66
 
46
67
  # get a list of cached measure results for a single patient
47
- sample_patient = get_db()['patient_cache'].find().first()
68
+ sample_patient = QME::PatientCache.where({}).first
48
69
  if sample_patient
49
- cached_results = get_db()['patient_cache'].find({'value.patient_id' => sample_patient['value']['patient_id']})
70
+ cached_results = QME::PatientCache.where({'value.patient_id' => sample_patient['value']['patient_id']})
50
71
 
51
72
  # for each cached result (a combination of measure_id, sub_id, effective_date and test_id)
52
73
  cached_results.each do |measure|
@@ -60,27 +81,25 @@ module QME
60
81
 
61
82
  # remove the query totals so they will be recalculated using the new results for
62
83
  # the modified patient
63
- get_db()["query_cache"].drop()
84
+ self.destroy_all
64
85
  end
65
86
 
66
- # Creates a new QualityReport
67
- # @param [String] measure_id value of the measure's id field
68
- # @param [String] sub_id value of the measure's sub_id field, may be nil
69
- # for measures with only a single numerator and denominator
70
- # @param [Hash] parameter_values slots in the measure definition that need to
71
- # be filled in and an optional test_id to identify a sub-population.
72
- def initialize(measure_id, sub_id, parameter_values)
73
- @measure_id = measure_id
74
- @sub_id = sub_id
87
+
88
+
89
+
90
+ def self.find_or_create(measure_id, sub_id, parameter_values)
75
91
  @parameter_values = parameter_values
76
- determine_connection_information
92
+ @parameter_values[:filters] = self.normalize_filters(@parameter_values[:filters])
93
+ query = {measure_id: measure_id, sub_id: sub_id}
94
+ query.merge! @parameter_values
95
+ self.find_or_create_by(query)
77
96
  end
78
97
 
79
98
  # Determines whether the quality report has been calculated for the given
80
99
  # measure and parameters
81
100
  # @return [true|false]
82
101
  def calculated?
83
- ! result().nil?
102
+ self.status["state"] == "completed"
84
103
  end
85
104
 
86
105
  # Determines whether the patient mapping for the quality report has been
@@ -89,15 +108,19 @@ module QME
89
108
  ! patient_result().nil?
90
109
  end
91
110
 
111
+
92
112
  # Kicks off a background job to calculate the measure
93
113
  # @return a unique id for the measure calculation job
94
- def calculate(asynchronous=true)
95
-
96
- options = {'measure_id' => @measure_id, 'sub_id' => @sub_id}
114
+ def calculate(parameters, asynchronous=true)
115
+
116
+ options = {'quality_report_id' => self.id}
117
+ options.merge! parameters || {}
97
118
 
98
- options.merge! @parameter_values
99
- options['filters'] = QME::QualityReport.normalize_filters(@parameter_values['filters'])
119
+ if self.status["state"] == "completed" && !options["recalculate"]
120
+ return self
121
+ end
100
122
 
123
+ self.status["state"] = "queued"
101
124
  if (asynchronous)
102
125
  job = Delayed::Job.enqueue(QME::MapReduce::MeasureCalculationJob.new(options))
103
126
  job._id
@@ -107,59 +130,60 @@ module QME
107
130
  end
108
131
  end
109
132
 
110
- # Returns the status of a measure calculation job
111
- # @param job_id the id of the job to check on
112
- # @return [Symbol] Will return the status: :complete, :queued, :running, :failed
113
- def status(job_id)
114
- job = Delayed::Job.where(_id: job_id).first
115
- if job.nil?
116
- # If we can't find the job, we assume that it is complete
117
- :complete
118
- else
119
- if job.locked_at.nil?
120
- :queued
121
- else
122
- if job.failed?
123
- :failed
124
- else
125
- :running
126
- end
127
- end
128
- end
133
+ def patient_results
134
+ ex = QME::MapReduce::Executor.new(self.measure_id,self.sub_id, self.attributes)
135
+ QME::PatientCache.where(patient_cache_matcher)
129
136
  end
130
-
131
- # Gets the result of running a quality measure
132
- # @return [Hash] measure groups (like numerator) as keys, counts as values or nil if
133
- # the measure has not yet been calculated
134
- def result
135
- cache = get_db()["query_cache"]
136
- query = {:measure_id => @measure_id, :sub_id => @sub_id,
137
- :effective_date => @parameter_values['effective_date'],
138
- :test_id => @parameter_values['test_id']}
139
- if @parameter_values['filters']
140
- query.merge!({filters: QME::QualityReport.normalize_filters(@parameter_values['filters'])})
141
- else
142
- query.merge!({filters: nil})
143
- end
144
-
145
- cache.find(query).first()
137
+
138
+ def measure
139
+ QME::QualityMeasure.where({"hqmf_id"=>self.measure_id, "sub_id" => self.sub_id}).first
146
140
  end
147
-
141
+
148
142
  # make sure all filter id arrays are sorted
149
143
  def self.normalize_filters(filters)
150
144
  filters.each {|key, value| value.sort_by! {|v| (v.is_a? Hash) ? "#{v}" : v} if value.is_a? Array} unless filters.nil?
151
145
  end
152
146
 
153
147
  def patient_result(patient_id = nil)
154
- cache = get_db()["patient_cache"]
155
- query = {'value.measure_id' => @measure_id, 'value.sub_id' => @sub_id,
156
- 'value.effective_date' => @parameter_values['effective_date'],
157
- 'value.test_id' => @parameter_values['test_id']}
148
+ query = patient_cache_matcher
158
149
  if patient_id
159
150
  query['value.medical_record_id'] = patient_id
160
151
  end
161
- cache.find(query).first()
152
+ QME::PatientCache.where(query).first()
162
153
  end
163
-
154
+
155
+
156
+ def patient_cache_matcher
157
+ match = {'value.measure_id' => self.measure_id,
158
+ 'value.sub_id' => self.sub_id,
159
+ 'value.effective_date' => self.effective_date,
160
+ 'value.test_id' => test_id,
161
+ 'value.manual_exclusion' => {'$in' => [nil, false]}}
162
+
163
+ if(filters)
164
+ if (filters['races'] && filters['races'].size > 0)
165
+ match['value.race.code'] = {'$in' => filters['races']}
166
+ end
167
+ if (filters['ethnicities'] && filters['ethnicities'].size > 0)
168
+ match['value.ethnicity.code'] = {'$in' => filters['ethnicities']}
169
+ end
170
+ if (filters['genders'] && filters['genders'].size > 0)
171
+ match['value.gender'] = {'$in' => filters['genders']}
172
+ end
173
+ if (filters['providers'] && filters['providers'].size > 0)
174
+
175
+ providers = filters['providers'].map { |pv| {'providers' => Moped::BSON::ObjectId(pv) } }
176
+ match['value.provider_performances.provider_id']= {'$in' => providers}
177
+ end
178
+ if (filters['languages'] && filters['languages'].size > 0)
179
+ match["value.languages"] = {'$in' => filters['languages']}
180
+ end
181
+ end
182
+ match
164
183
  end
184
+
185
+
186
+ end
187
+
188
+
165
189
  end
data/lib/qme/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module QME
2
- VERSION = "2.5.3"
2
+ VERSION = "3.0.0.beta.1"
3
3
  end
@@ -9,6 +9,8 @@ require "qme/version"
9
9
  require 'qme/database_access'
10
10
  require 'qme/quality_measure'
11
11
  require 'qme/quality_report'
12
+ require 'qme/patient_cache'
13
+ require 'qme/manual_exclusion'
12
14
 
13
15
  require 'qme/map/map_reduce_builder'
14
16
  require 'qme/map/map_reduce_executor'
@@ -17,8 +19,5 @@ require 'qme/map/cv_aggregator'
17
19
 
18
20
 
19
21
 
20
- require 'qme/bundle/eh_measure_sheet'
21
- require 'qme/bundle/eh_patient_importer'
22
-
23
22
 
24
23
  require 'qme/railtie' if defined?(Rails)
@@ -41,5 +41,11 @@ root.map = function(record, population, denominator, numerator, exclusion, denex
41
41
 
42
42
  if (typeof Logger != 'undefined') value['logger'] = Logger.logger
43
43
 
44
+ value.measure_id = hqmfjs.hqmf_id
45
+ value.sub_id = hqmfjs.sub_id
46
+ value.nqf_id = hqmfjs.nqf_id
47
+ value.test_id = hqmfjs.test_id
48
+ value.effective_date = hqmfjs.effective_date;
49
+
44
50
  emit(ObjectId(), value);
45
51
  };
@@ -621,7 +621,7 @@
621
621
  "conjunction": "and",
622
622
  "items": []
623
623
  },
624
- "map_fn": "function() {\n var patient = this;\n var effective_date = <%= effective_date %>;\n\n hqmfjs = {}\n <%= init_js_frameworks %>\n \n \n var patient_api = new hQuery.Patient(patient);\n\n \n\n // clear out logger\n if (typeof Logger != 'undefined') Logger.logger = [];\n // turn on logging if it is enabled\n if (Logger.enabled) enableLogging();\n \n \n // #########################\n // ##### DATA ELEMENTS #####\n // #########################\n\n OidDictionary = {'2.16.840.1.113883.3.464.0001.231':{'CPT':['99201','99202','99203','99204','99205','99211','99212','99213','99214','99215','99217','99218','99219','99220','99241','99242','99243','99244','99245','99384','99385','99394','99395','99401','99402','99403','99404','99411','99412','99420','99429'],'ICD-9-CM':['V70.0','V70.3','V70.5','V70.6','V70.8','V70.9']},'2.16.840.1.113883.3.464.0001.250':{'CPT':['87070','87071','87081','87430','87650','87651','87652','87880'],'LOINC':['11268-0','17656-0','18481-2','31971-5','49610-9','5036-9','626-2','6556-5','6557-3','6558-1','6559-9'],'SNOMED-CT':['89634005.0','122121004.0','122205003.0','122245007.0','122303007.0']},'2.16.840.1.113883.3.464.0001.369':{'ICD-9-CM':['034.0','462.0','463.0'],'SNOMED-CT':['140004.0','652005.0','1532007.0','2091005.0','2365002.0','10351008.0','11461005.0','13177009.0','14465002.0','17741008.0','23166004.0','24078009.0','27878001.0','31309002.0','39271004.0','40766000.0','41582007.0','43878008.0','47841006.0','51209006.0','51476001.0','55355000.0','58031004.0','59221008.0','59471009.0','63866002.0','70020005.0','72430001.0','76651006.0','78430008.0','78911000.0','82228008.0','87326000.0','90176007.0','90979004.0','95885008.0','102453009.0','109362006.0','111277007.0','111816002.0','111816002.0','126664009.0','164260005.0','186659004.0','186675001.0','186963008.0','195655000.0','195655000.0','195656004.0','195657008.0','195658003.0','195659006.0','195660001.0','195662009.0','195662009.0','195663004.0','195666007.0','195667003.0','195668008.0','195669000.0','195670004.0','195671000.0','195672007.0','195673002.0','195676005.0','195677001.0','195707008.0','195779005.0','195780008.0','195782000.0','195798007.0','195803003.0','195804009.0','195924009.0','232399005.0','232400003.0','232401004.0','232402006.0','232403001.0','232404007.0','232405008.0','232405008.0','232406009.0','232417005.0','232420002.0','234528007.0','240444009.0','240547000.0','300932000.0','302911003.0','312422001.0','363746003.0','399095008.0','405737000.0','415724006.0','J02','J02.0','J02.8','J02.9','J03','J03.0','J03.00','J03.01','J03.8','J03.80','J03.81','J03.9','J03.90','J03.91']},'2.16.840.1.113883.3.464.0001.373':{'RxNorm':['197450','197451','200346','204871','250156','309054','309058','309076','309077','309078','309079','309085','309086','309087','309090','309091','309092','309093','351127','419849','476576','562619','645956','746671','847360']},'2.16.840.1.113883.3.464.0001.157':{'RxNorm':['105134.0','105152.0','199693.0','199694.0','199928.0','199997.0','239187.0','239191.0','240984.0','246282.0','250463.0','308177.0','308181.0','308182.0','308183.0','308188.0','308189.0','308191.0','308192.0','308194.0','308207.0','308208.0','308209.0','308210.0','308212.0','313797.0','313798.0','313799.0','313800.0','313801.0','313819.0','313850.0','346892.0','392151.0','392152.0','403945.0','476299.0','562255.0','562256.0','598025.0','746669.0','756252.0','789980.0','791939.0','791947.0','802550.0','846994.0','852904.0','308206']},'2.16.840.1.113883.3.464.0001.172':{'RxNorm':['562251.0','562253.0','562508.0','617293.0','617295.0','617296.0','617302.0','617304.0','617309.0','617316.0','617322.0','617423.0','617430.0','617975.0','617976.0','617981.0','617989.0','617993.0','617995.0','617996.0','645806.0']},'2.16.840.1.113883.3.560.100.4':{'LOINC':['21112-8']},'2.16.840.1.113883.3.464.0001.45':{'CPT':['99281','99282','99283','99284','99285']},'2.16.840.1.113883.3.464.0001.48':{'CPT':['99201','99202','99203','99204','99205','99211','99212','99213','99214','99215','99217','99218','99219','99220','99241','99242','99243','99244','99245','99384','99385','99394','99395','99401','99402','99403','99404','99411','99412','99420','99429']},'2.16.840.1.113883.3.464.0001.50':{'ICD-9-CM':['V70.0','V70.3','V70.5','V70.6','V70.8','V70.9']},'2.16.840.1.113883.3.464.0001.246':{'RxNorm':['105170.0','105171.0','197454.0','197455.0','197456.0','242794.0','250582.0','309046.0','309047.0','309048.0','309049.0','309051.0','309052.0','309053.0','309110.0','309111.0','309112.0','309113.0','309114.0','309115.0','309121.0','313889.0','313920.0','313929.0','347996.0','406696.0','476193.0','562062.0','562641.0','637173.0','645617.0','755615.0','755616.0','755617.0','796301.0','854220.0']},'2.16.840.1.113883.3.464.0001.247':{'RxNorm':['108449.0','141843.0','198332.0','198333.0','244967.0','562707.0']},'2.16.840.1.113883.3.464.0001.249':{'CPT':['87070','87071','87081','87430','87650','87651','87652','87880']},'2.16.840.1.113883.3.464.0001.251':{'LOINC':['11268-0','17656-0','18481-2','31971-5','49610-9','5036-9','626-2','6556-5','6557-3','6558-1','6559-9']},'2.16.840.1.113883.3.464.0001.252':{'SNOMED-CT':['89634005.0','122121004.0','122205003.0','122245007.0','122303007.0']},'2.16.840.1.113883.3.464.0001.302':{'RxNorm':['141970.0','197518.0','197519.0','205964.0','259233.0','284215.0','309329.0','309332.0','309333.0','309335.0','309336.0','309337.0','309338.0','309339.0','309340.0','358917.0','392275.0','477451.0','562266.0','745483.0','797274.0','853019.0','882548.0','885131.0','890921.0','900391.0','900424.0','900460.0']},'2.16.840.1.113883.3.464.0001.308':{'RxNorm':['204844.0','248656.0','251854.0','141962.0','141963.0','197516.0','197517.0','197650.0','206085.0','240741.0','259543.0','308459.0','308460.0','308461.0','309321.0','309322.0','310157.0','310160.0','310161.0','310162.0','310165.0','346618.0','359385.0','486912.0','486955.0','486960.0','487129.0','577162.0','577378.0','597193.0','597194.0','597298.0','597455.0','686350.0','686354.0','686355.0','686400.0','686405.0','686406.0','686418.0','686447.0','750151.0','751864.0','861416.0']},'2.16.840.1.113883.3.464.0001.341':{'RxNorm':['105078.0','204466.0','207390.0','207391.0','312260.0','312263.0','312266.0','312270.0','617857.0','617881.0','623677.0','623695.0','731538.0','731558.0','731560.0','731564.0','731567.0','731570.0','731572.0','731575.0','731590.0','745047.0','745051.0','745053.0','745276.0','745278.0','745280.0','745282.0','745284.0','745286.0','745292.0','745296.0','745300.0','745302.0','745303.0','745462.0','745464.0','745477.0','745479.0','745519.0','745560.0','745561.0','745585.0','824584.0','834040.0','834046.0','834061.0','834102.0','834179.0','834182.0','836306.0','863538.0']},'2.16.840.1.113883.3.464.0001.368':{'RxNorm':['197595.0','197596.0','309860.0','313945.0','406366.0']},'2.16.840.1.113883.3.464.0001.371':{'ICD-9-CM':['034.0','462.0','463.0']},'2.16.840.1.113883.3.464.0001.372':{'SNOMED-CT':['140004.0','652005.0','1532007.0','2091005.0','2365002.0','10351008.0','11461005.0','13177009.0','14465002.0','17741008.0','23166004.0','24078009.0','27878001.0','31309002.0','39271004.0','40766000.0','41582007.0','43878008.0','47841006.0','51209006.0','51476001.0','55355000.0','58031004.0','59221008.0','59471009.0','63866002.0','70020005.0','72430001.0','76651006.0','78430008.0','78911000.0','82228008.0','87326000.0','90176007.0','90979004.0','95885008.0','102453009.0','109362006.0','111277007.0','111816002.0','111816002.0','126664009.0','164260005.0','186659004.0','186675001.0','186963008.0','195655000.0','195655000.0','195656004.0','195657008.0','195658003.0','195659006.0','195660001.0','195662009.0','195662009.0','195663004.0','195666007.0','195667003.0','195668008.0','195669000.0','195670004.0','195671000.0','195672007.0','195673002.0','195676005.0','195677001.0','195707008.0','195779005.0','195780008.0','195782000.0','195798007.0','195803003.0','195804009.0','195924009.0','232399005.0','232400003.0','232401004.0','232402006.0','232403001.0','232404007.0','232405008.0','232405008.0','232406009.0','232417005.0','232420002.0','234528007.0','240444009.0','240547000.0','300932000.0','302911003.0','312422001.0','363746003.0','399095008.0','405737000.0','415724006.0','J02','J02.0','J02.8','J02.9','J03','J03.0','J03.00','J03.01','J03.8','J03.80','J03.81','J03.9','J03.90','J03.91']},'2.16.840.1.113883.3.464.0001.385':{'RxNorm':['197511.0','197512.0','198044.0','198048.0','198049.0','198050.0','199370.0','199886.0','240639.0','240640.0','250095.0','259311.0','309304.0','309308.0','309309.0','309310.0','310445.0','311296.0','311364.0','311787.0','313522.0','313523.0','314009.0','315065.0','351156.0','359383.0','403921.0','477391.0','597446.0','637560.0','644541.0','794769.0','877486.0']},'2.16.840.1.113883.3.464.0001.397':{'RxNorm':['105189','197449','197452','197453','197898','197899','204929','245239','309040','309041','309042','309043','309044','309045','309080','309081','309095','309096','309097','309098','309099','309100','309101','309103','311370','311371','313888','313926','349507','349508','387065','387066','476322','476325','476327','476623']},'2.16.840.1.113883.3.464.0001.406':{'RxNorm':['142118.0','198334.0','198335.0','313137.0','648254.0','686383.0','894883.0','198235','198420','246252','312340','313134','315219','413716','756189']},'2.16.840.1.113883.3.464.0001.408':{'RxNorm':['105220','105227','197633','197984','197985','198249','198250','198252','199026','199027','207362','207364','242807','242814','283535','310026','310027','310028','310029','310030','313251','313252','313253','313254','314108','317127','348869','348870','349114','349115','349116','351121','359465','403840','406524','434018','597520','597521','597808','629695','629697','629699','630819','630824','630827','643821','645613','645614','645619','647109','687231','700408','705861','728207','756134','756192','799048','858062','858065','858372','858375']},'2.16.840.1.113883.3.464.0001.409':{'RxNorm':['197450','197451','200346','204871','250156','309054','309058','309076','309077','309078','309079','309085','309086','309087','309090','309091','309092','309093','351127','419849','476576','562619','645956','746671','847360']}};\n // Measure variables\nvar MeasurePeriod = {\n \"low\": new TS(\"20100101\", null, true),\n \"high\": new TS(\"20110101\", null, true)\n}\nhqmfjs.MeasurePeriod = function(patient) {\n return [new hQuery.CodedEntry(\n {\n \"start_time\": MeasurePeriod.low.asDate().getTime()/1000,\n \"end_time\": MeasurePeriod.high.asDate().getTime()/1000,\n \"codes\": {}\n }\n )];\n}\nif (typeof effective_date === 'number') {\n MeasurePeriod.high.date = new Date(1000*effective_date);\n MeasurePeriod.low.date = new Date(1000*effective_date);\n MeasurePeriod.low.date.setFullYear(MeasurePeriod.low.date.getFullYear()-1);\n}\n\n// Data critera\nhqmfjs.MedicationDispensedPharyngitisAntibiotics_precondition_4 = function(patient) {\n var events = patient.allMedications();\n events = events.withStatuses([\"dispensed\"]);\n events = events.withoutNegation();\n var codes = getCodes(\"2.16.840.1.113883.3.464.0001.373\");\n var start = null;\n var end = null;\n events = events.match(codes, start, end, true);\n\n events.specificContext=Specifics.identity()\n return events;\n}\n\nhqmfjs.MedicationOrderPharyngitisAntibiotics_precondition_6 = function(patient) {\n var events = patient.allMedications();\n events = events.withStatuses([\"ordered\"]);\n events = events.withoutNegation();\n var codes = getCodes(\"2.16.840.1.113883.3.464.0001.373\");\n var start = null;\n var end = null;\n events = events.match(codes, start, end, true);\n\n events.specificContext=Specifics.identity()\n return events;\n}\n\nhqmfjs.MedicationActivePharyngitisAntibiotics_precondition_8 = function(patient) {\n var events = patient.allMedications();\n events = events.withStatuses([\"active\"]);\n events = events.withoutNegation();\n var codes = getCodes(\"2.16.840.1.113883.3.464.0001.373\");\n var start = null;\n var end = null;\n events = events.match(codes, start, end, true);\n\n events.specificContext=Specifics.identity()\n return events;\n}\n\nhqmfjs.EncounterEncounterAmbulatoryIncludingPediatrics_precondition_1 = function(patient) {\n var events = patient.encounters();\n events = events.withoutNegation();\n var codes = getCodes(\"2.16.840.1.113883.3.464.0001.231\");\n var start = null;\n var end = null;\n events = events.match(codes, start, end, true);\n\n events = DURING(events, hqmfjs.MeasurePeriod(patient));\n events = SBS(events, hqmfjs.GROUP_SBS_CHILDREN_1(patient), new IVL_PQ(null, new PQ(3, \"d\", true)));\n return events;\n}\n\nhqmfjs.GROUP_SBS_CHILDREN_1 = function(patient) {\n var events = UNION(\n hqmfjs.MedicationDispensedPharyngitisAntibiotics_precondition_4(patient),\n hqmfjs.MedicationOrderPharyngitisAntibiotics_precondition_6(patient),\n hqmfjs.MedicationActivePharyngitisAntibiotics_precondition_8(patient)\n );\n\n events.specificContext=Specifics.identity()\n return events;\n}\n\nhqmfjs.LaboratoryTestPerformedGroupAStreptococcusTest_precondition_11 = function(patient) {\n var events = patient.laboratoryTests();\n events = events.withStatuses([\"performed\"]);\n events = events.withoutNegation();\n var codes = getCodes(\"2.16.840.1.113883.3.464.0001.250\");\n var start = null;\n var end = null;\n events = events.match(codes, start, end, true);\n\n events = SBE(events, hqmfjs.EncounterEncounterAmbulatoryIncludingPediatrics_precondition_1(patient), new IVL_PQ(null, new PQ(3, \"d\", true)));\n return events;\n}\n\nhqmfjs.MedicationDispensedPharyngitisAntibiotics_precondition_16 = function(patient) {\n var events = patient.allMedications();\n events = events.withStatuses([\"dispensed\"]);\n events = events.withoutNegation();\n var codes = getCodes(\"2.16.840.1.113883.3.464.0001.373\");\n var start = null;\n var end = null;\n events = events.match(codes, start, end, true);\n\n events.specificContext=Specifics.identity()\n return events;\n}\n\nhqmfjs.MedicationOrderPharyngitisAntibiotics_precondition_18 = function(patient) {\n var events = patient.allMedications();\n events = events.withStatuses([\"ordered\"]);\n events = events.withoutNegation();\n var codes = getCodes(\"2.16.840.1.113883.3.464.0001.373\");\n var start = null;\n var end = null;\n events = events.match(codes, start, end, true);\n\n events.specificContext=Specifics.identity()\n return events;\n}\n\nhqmfjs.MedicationActivePharyngitisAntibiotics_precondition_20 = function(patient) {\n var events = patient.allMedications();\n events = events.withStatuses([\"active\"]);\n events = events.withoutNegation();\n var codes = getCodes(\"2.16.840.1.113883.3.464.0001.373\");\n var start = null;\n var end = null;\n events = events.match(codes, start, end, true);\n\n events.specificContext=Specifics.identity()\n return events;\n}\n\nhqmfjs.EncounterEncounterAmbulatoryIncludingPediatrics_precondition_13 = function(patient) {\n var events = patient.encounters();\n events = events.withoutNegation();\n var codes = getCodes(\"2.16.840.1.113883.3.464.0001.231\");\n var start = null;\n var end = null;\n events = events.match(codes, start, end, true);\n\n events = DURING(events, hqmfjs.MeasurePeriod(patient));\n events = SBS(events, hqmfjs.GROUP_SBS_CHILDREN_2(patient), new IVL_PQ(null, new PQ(3, \"d\", true)));\n return events;\n}\n\nhqmfjs.GROUP_SBS_CHILDREN_2 = function(patient) {\n var events = UNION(\n hqmfjs.MedicationDispensedPharyngitisAntibiotics_precondition_16(patient),\n hqmfjs.MedicationOrderPharyngitisAntibiotics_precondition_18(patient),\n hqmfjs.MedicationActivePharyngitisAntibiotics_precondition_20(patient)\n );\n\n events.specificContext=Specifics.identity()\n return events;\n}\n\nhqmfjs.LaboratoryTestPerformedGroupAStreptococcusTest_precondition_23 = function(patient) {\n var events = patient.laboratoryTests();\n events = events.withStatuses([\"performed\"]);\n events = events.withoutNegation();\n var codes = getCodes(\"2.16.840.1.113883.3.464.0001.250\");\n var start = null;\n var end = null;\n events = events.match(codes, start, end, true);\n\n events = SAE(events, hqmfjs.EncounterEncounterAmbulatoryIncludingPediatrics_precondition_13(patient), new IVL_PQ(null, new PQ(3, \"d\", true)));\n return events;\n}\n\nhqmfjs.EncounterEncounterAmbulatoryIncludingPediatrics_precondition_26 = function(patient) {\n var events = patient.encounters();\n events = events.withoutNegation();\n var codes = getCodes(\"2.16.840.1.113883.3.464.0001.231\");\n var start = null;\n var end = null;\n events = events.match(codes, start, end, true);\n\n events = DURING(events, hqmfjs.MeasurePeriod(patient));\n return events;\n}\n\nhqmfjs.EncounterEncounterAmbulatoryIncludingPediatrics_precondition_28 = function(patient) {\n var events = patient.encounters();\n events = events.withoutNegation();\n var codes = getCodes(\"2.16.840.1.113883.3.464.0001.231\");\n var start = null;\n var end = null;\n events = events.match(codes, start, end, true);\n\n events = DURING(events, hqmfjs.MeasurePeriod(patient));\n return events;\n}\n\nhqmfjs.DiagnosisActivePharyngitis_precondition_29 = function(patient) {\n var events = patient.allProblems();\n events = events.withStatuses([\"active\"]);\n events = events.withoutNegation();\n var codes = getCodes(\"2.16.840.1.113883.3.464.0001.369\");\n var start = null;\n var end = null;\n events = events.match(codes, start, end, true);\n\n events = DURING(events, hqmfjs.EncounterEncounterAmbulatoryIncludingPediatrics_precondition_28(patient));\n return events;\n}\n\nhqmfjs.MedicationDispensedPharyngitisAntibiotics_precondition_34 = function(patient) {\n var events = patient.allMedications();\n events = events.withStatuses([\"dispensed\"]);\n events = events.withoutNegation();\n var codes = getCodes(\"2.16.840.1.113883.3.464.0001.373\");\n var start = null;\n var end = null;\n events = events.match(codes, start, end, true);\n\n events.specificContext=Specifics.identity()\n return events;\n}\n\nhqmfjs.MedicationOrderPharyngitisAntibiotics_precondition_36 = function(patient) {\n var events = patient.allMedications();\n events = events.withStatuses([\"ordered\"]);\n events = events.withoutNegation();\n var codes = getCodes(\"2.16.840.1.113883.3.464.0001.373\");\n var start = null;\n var end = null;\n events = events.match(codes, start, end, true);\n\n events.specificContext=Specifics.identity()\n return events;\n}\n\nhqmfjs.MedicationActivePharyngitisAntibiotics_precondition_38 = function(patient) {\n var events = patient.allMedications();\n events = events.withStatuses([\"active\"]);\n events = events.withoutNegation();\n var codes = getCodes(\"2.16.840.1.113883.3.464.0001.373\");\n var start = null;\n var end = null;\n events = events.match(codes, start, end, true);\n\n events.specificContext=Specifics.identity()\n return events;\n}\n\nhqmfjs.EncounterEncounterAmbulatoryIncludingPediatrics_precondition_31 = function(patient) {\n var events = patient.encounters();\n events = events.withoutNegation();\n var codes = getCodes(\"2.16.840.1.113883.3.464.0001.231\");\n var start = null;\n var end = null;\n events = events.match(codes, start, end, true);\n\n events = DURING(events, hqmfjs.MeasurePeriod(patient));\n events = SBS(events, hqmfjs.GROUP_SBS_CHILDREN_3(patient), new IVL_PQ(null, new PQ(3, \"d\", true)));\n return events;\n}\n\nhqmfjs.GROUP_SBS_CHILDREN_3 = function(patient) {\n var events = UNION(\n hqmfjs.MedicationDispensedPharyngitisAntibiotics_precondition_34(patient),\n hqmfjs.MedicationOrderPharyngitisAntibiotics_precondition_36(patient),\n hqmfjs.MedicationActivePharyngitisAntibiotics_precondition_38(patient)\n );\n\n events.specificContext=Specifics.identity()\n return events;\n}\n\nhqmfjs.EncounterEncounterAmbulatoryIncludingPediatrics_precondition_49 = function(patient) {\n var events = patient.encounters();\n events = events.withoutNegation();\n var codes = getCodes(\"2.16.840.1.113883.3.464.0001.231\");\n var start = null;\n var end = null;\n events = events.match(codes, start, end, true);\n\n events = DURING(events, hqmfjs.MeasurePeriod(patient));\n return events;\n}\n\nhqmfjs.MedicationDispensedPharyngitisAntibiotics_precondition_42 = function(patient) {\n var events = patient.allMedications();\n events = events.withStatuses([\"dispensed\"]);\n events = events.withoutNegation();\n var codes = getCodes(\"2.16.840.1.113883.3.464.0001.373\");\n var start = null;\n var end = null;\n events = events.match(codes, start, end, true);\n\n events = SBS(events, hqmfjs.EncounterEncounterAmbulatoryIncludingPediatrics_precondition_49(patient), new IVL_PQ(null, new PQ(30, \"d\", true)));\n return events;\n}\n\nhqmfjs.MedicationOrderPharyngitisAntibiotics_precondition_44 = function(patient) {\n var events = patient.allMedications();\n events = events.withStatuses([\"ordered\"]);\n events = events.withoutNegation();\n var codes = getCodes(\"2.16.840.1.113883.3.464.0001.373\");\n var start = null;\n var end = null;\n events = events.match(codes, start, end, true);\n\n events = SBS(events, hqmfjs.EncounterEncounterAmbulatoryIncludingPediatrics_precondition_49(patient), new IVL_PQ(null, new PQ(30, \"d\", true)));\n return events;\n}\n\nhqmfjs.MedicationActivePharyngitisAntibiotics_precondition_46 = function(patient) {\n var events = patient.allMedications();\n events = events.withStatuses([\"active\"]);\n events = events.withoutNegation();\n var codes = getCodes(\"2.16.840.1.113883.3.464.0001.373\");\n var start = null;\n var end = null;\n events = events.match(codes, start, end, true);\n\n events = SBS(events, hqmfjs.EncounterEncounterAmbulatoryIncludingPediatrics_precondition_49(patient), new IVL_PQ(null, new PQ(30, \"d\", true)));\n return events;\n}\n\nhqmfjs.PatientCharacteristicBirthDate_precondition_53 = function(patient) {\nvar value = patient.birthtime();\nvar events = [value];\nevents = SBS(events, hqmfjs.MeasurePeriod(patient), new IVL_PQ(new PQ(2, \"a\", true), null));\nevents.specificContext=Specifics.identity();\nreturn events;\n\n}\n\nhqmfjs.PatientCharacteristicBirthDate_precondition_55 = function(patient) {\nvar value = patient.birthtime();\nvar events = [value];\nevents = SBS(events, hqmfjs.MeasurePeriod(patient), new IVL_PQ(null, new PQ(17, \"a\", true)));\nevents.specificContext=Specifics.identity();\nreturn events;\n\n}\n\n\n\n // #########################\n // ##### MEASURE LOGIC #####\n // #########################\n \n hqmfjs.initializeSpecifics = function(patient_api, hqmfjs) { Specifics.initialize(patient_api,hqmfjs) }\n\n // INITIAL PATIENT POPULATION\n hqmfjs.IPP = function(patient) {\n return allTrue( \n allTrue( \n hqmfjs.PatientCharacteristicBirthDate_precondition_53(patient), \n hqmfjs.PatientCharacteristicBirthDate_precondition_55(patient)\n )\n );\n};\n\n\n // DENOMINATOR\n hqmfjs.DENOM = function(patient) {\n return allTrue( \n allTrue( \n hqmfjs.EncounterEncounterAmbulatoryIncludingPediatrics_precondition_26(patient), \n hqmfjs.DiagnosisActivePharyngitis_precondition_29(patient), \n atLeastOneTrue( \n hqmfjs.EncounterEncounterAmbulatoryIncludingPediatrics_precondition_31(patient)\n ), \n atLeastOneFalse( \n atLeastOneTrue( \n hqmfjs.MedicationDispensedPharyngitisAntibiotics_precondition_42(patient), \n hqmfjs.MedicationOrderPharyngitisAntibiotics_precondition_44(patient), \n hqmfjs.MedicationActivePharyngitisAntibiotics_precondition_46(patient)\n )\n )\n )\n );\n};\n\n\n // NUMERATOR\n hqmfjs.NUMER = function(patient) {\n return allTrue( \n allTrue( \n hqmfjs.LaboratoryTestPerformedGroupAStreptococcusTest_precondition_11(patient), \n hqmfjs.LaboratoryTestPerformedGroupAStreptococcusTest_precondition_23(patient)\n )\n );\n};\n\n\n hqmfjs.EXCL = function(patient) { return new Boolean(false); }\n hqmfjs.DENEXCEP = function(patient) { return new Boolean(false); }\n \n\n hqmfjs.initializeSpecifics(patient_api, hqmfjs)\n \n var population = function() {\n return executeIfAvailable(hqmfjs.IPP, patient_api);\n }\n var denominator = function() {\n return executeIfAvailable(hqmfjs.DENOM, patient_api);\n }\n var numerator = function() {\n return executeIfAvailable(hqmfjs.NUMER, patient_api);\n }\n var exclusion = function() {\n return executeIfAvailable(hqmfjs.EXCL, patient_api);\n }\n var denexcep = function() {\n return executeIfAvailable(hqmfjs.DENEXCEP, patient_api);\n }\n \n var executeIfAvailable = function(optionalFunction, arg) {\n if (typeof(optionalFunction)==='function')\n return optionalFunction(arg);\n else\n return false;\n }\n\n if (Logger.enabled) enableMeasureLogging(hqmfjs);\n\n map(patient, population, denominator, numerator, exclusion, denexcep);\n \n };\n ",
624
+ "map_fn": "function() {\n var patient = this;\n var effective_date = <%= effective_date %>;\n\n hqmfjs = {}\n hqmfjs.hqmf_id = '2E679CD2-3FEC-4A75-A75A-61403E5EFEE8'; hqmfjs.sub_id = null; hqmfjs.nqf_id = '0002'; hqmfjs.test_id=null; hqmfjs.effective_date = effective_date;\n <%= init_js_frameworks %>\n \n \n var patient_api = new hQuery.Patient(patient);\n\n \n\n // clear out logger\n if (typeof Logger != 'undefined') Logger.logger = [];\n // turn on logging if it is enabled\n if (Logger.enabled) enableLogging();\n \n \n // #########################\n // ##### DATA ELEMENTS #####\n // #########################\n\n OidDictionary = {'2.16.840.1.113883.3.464.0001.231':{'CPT':['99201','99202','99203','99204','99205','99211','99212','99213','99214','99215','99217','99218','99219','99220','99241','99242','99243','99244','99245','99384','99385','99394','99395','99401','99402','99403','99404','99411','99412','99420','99429'],'ICD-9-CM':['V70.0','V70.3','V70.5','V70.6','V70.8','V70.9']},'2.16.840.1.113883.3.464.0001.250':{'CPT':['87070','87071','87081','87430','87650','87651','87652','87880'],'LOINC':['11268-0','17656-0','18481-2','31971-5','49610-9','5036-9','626-2','6556-5','6557-3','6558-1','6559-9'],'SNOMED-CT':['89634005.0','122121004.0','122205003.0','122245007.0','122303007.0']},'2.16.840.1.113883.3.464.0001.369':{'ICD-9-CM':['034.0','462.0','463.0'],'SNOMED-CT':['140004.0','652005.0','1532007.0','2091005.0','2365002.0','10351008.0','11461005.0','13177009.0','14465002.0','17741008.0','23166004.0','24078009.0','27878001.0','31309002.0','39271004.0','40766000.0','41582007.0','43878008.0','47841006.0','51209006.0','51476001.0','55355000.0','58031004.0','59221008.0','59471009.0','63866002.0','70020005.0','72430001.0','76651006.0','78430008.0','78911000.0','82228008.0','87326000.0','90176007.0','90979004.0','95885008.0','102453009.0','109362006.0','111277007.0','111816002.0','111816002.0','126664009.0','164260005.0','186659004.0','186675001.0','186963008.0','195655000.0','195655000.0','195656004.0','195657008.0','195658003.0','195659006.0','195660001.0','195662009.0','195662009.0','195663004.0','195666007.0','195667003.0','195668008.0','195669000.0','195670004.0','195671000.0','195672007.0','195673002.0','195676005.0','195677001.0','195707008.0','195779005.0','195780008.0','195782000.0','195798007.0','195803003.0','195804009.0','195924009.0','232399005.0','232400003.0','232401004.0','232402006.0','232403001.0','232404007.0','232405008.0','232405008.0','232406009.0','232417005.0','232420002.0','234528007.0','240444009.0','240547000.0','300932000.0','302911003.0','312422001.0','363746003.0','399095008.0','405737000.0','415724006.0','J02','J02.0','J02.8','J02.9','J03','J03.0','J03.00','J03.01','J03.8','J03.80','J03.81','J03.9','J03.90','J03.91']},'2.16.840.1.113883.3.464.0001.373':{'RxNorm':['197450','197451','200346','204871','250156','309054','309058','309076','309077','309078','309079','309085','309086','309087','309090','309091','309092','309093','351127','419849','476576','562619','645956','746671','847360']},'2.16.840.1.113883.3.464.0001.157':{'RxNorm':['105134.0','105152.0','199693.0','199694.0','199928.0','199997.0','239187.0','239191.0','240984.0','246282.0','250463.0','308177.0','308181.0','308182.0','308183.0','308188.0','308189.0','308191.0','308192.0','308194.0','308207.0','308208.0','308209.0','308210.0','308212.0','313797.0','313798.0','313799.0','313800.0','313801.0','313819.0','313850.0','346892.0','392151.0','392152.0','403945.0','476299.0','562255.0','562256.0','598025.0','746669.0','756252.0','789980.0','791939.0','791947.0','802550.0','846994.0','852904.0','308206']},'2.16.840.1.113883.3.464.0001.172':{'RxNorm':['562251.0','562253.0','562508.0','617293.0','617295.0','617296.0','617302.0','617304.0','617309.0','617316.0','617322.0','617423.0','617430.0','617975.0','617976.0','617981.0','617989.0','617993.0','617995.0','617996.0','645806.0']},'2.16.840.1.113883.3.560.100.4':{'LOINC':['21112-8']},'2.16.840.1.113883.3.464.0001.45':{'CPT':['99281','99282','99283','99284','99285']},'2.16.840.1.113883.3.464.0001.48':{'CPT':['99201','99202','99203','99204','99205','99211','99212','99213','99214','99215','99217','99218','99219','99220','99241','99242','99243','99244','99245','99384','99385','99394','99395','99401','99402','99403','99404','99411','99412','99420','99429']},'2.16.840.1.113883.3.464.0001.50':{'ICD-9-CM':['V70.0','V70.3','V70.5','V70.6','V70.8','V70.9']},'2.16.840.1.113883.3.464.0001.246':{'RxNorm':['105170.0','105171.0','197454.0','197455.0','197456.0','242794.0','250582.0','309046.0','309047.0','309048.0','309049.0','309051.0','309052.0','309053.0','309110.0','309111.0','309112.0','309113.0','309114.0','309115.0','309121.0','313889.0','313920.0','313929.0','347996.0','406696.0','476193.0','562062.0','562641.0','637173.0','645617.0','755615.0','755616.0','755617.0','796301.0','854220.0']},'2.16.840.1.113883.3.464.0001.247':{'RxNorm':['108449.0','141843.0','198332.0','198333.0','244967.0','562707.0']},'2.16.840.1.113883.3.464.0001.249':{'CPT':['87070','87071','87081','87430','87650','87651','87652','87880']},'2.16.840.1.113883.3.464.0001.251':{'LOINC':['11268-0','17656-0','18481-2','31971-5','49610-9','5036-9','626-2','6556-5','6557-3','6558-1','6559-9']},'2.16.840.1.113883.3.464.0001.252':{'SNOMED-CT':['89634005.0','122121004.0','122205003.0','122245007.0','122303007.0']},'2.16.840.1.113883.3.464.0001.302':{'RxNorm':['141970.0','197518.0','197519.0','205964.0','259233.0','284215.0','309329.0','309332.0','309333.0','309335.0','309336.0','309337.0','309338.0','309339.0','309340.0','358917.0','392275.0','477451.0','562266.0','745483.0','797274.0','853019.0','882548.0','885131.0','890921.0','900391.0','900424.0','900460.0']},'2.16.840.1.113883.3.464.0001.308':{'RxNorm':['204844.0','248656.0','251854.0','141962.0','141963.0','197516.0','197517.0','197650.0','206085.0','240741.0','259543.0','308459.0','308460.0','308461.0','309321.0','309322.0','310157.0','310160.0','310161.0','310162.0','310165.0','346618.0','359385.0','486912.0','486955.0','486960.0','487129.0','577162.0','577378.0','597193.0','597194.0','597298.0','597455.0','686350.0','686354.0','686355.0','686400.0','686405.0','686406.0','686418.0','686447.0','750151.0','751864.0','861416.0']},'2.16.840.1.113883.3.464.0001.341':{'RxNorm':['105078.0','204466.0','207390.0','207391.0','312260.0','312263.0','312266.0','312270.0','617857.0','617881.0','623677.0','623695.0','731538.0','731558.0','731560.0','731564.0','731567.0','731570.0','731572.0','731575.0','731590.0','745047.0','745051.0','745053.0','745276.0','745278.0','745280.0','745282.0','745284.0','745286.0','745292.0','745296.0','745300.0','745302.0','745303.0','745462.0','745464.0','745477.0','745479.0','745519.0','745560.0','745561.0','745585.0','824584.0','834040.0','834046.0','834061.0','834102.0','834179.0','834182.0','836306.0','863538.0']},'2.16.840.1.113883.3.464.0001.368':{'RxNorm':['197595.0','197596.0','309860.0','313945.0','406366.0']},'2.16.840.1.113883.3.464.0001.371':{'ICD-9-CM':['034.0','462.0','463.0']},'2.16.840.1.113883.3.464.0001.372':{'SNOMED-CT':['140004.0','652005.0','1532007.0','2091005.0','2365002.0','10351008.0','11461005.0','13177009.0','14465002.0','17741008.0','23166004.0','24078009.0','27878001.0','31309002.0','39271004.0','40766000.0','41582007.0','43878008.0','47841006.0','51209006.0','51476001.0','55355000.0','58031004.0','59221008.0','59471009.0','63866002.0','70020005.0','72430001.0','76651006.0','78430008.0','78911000.0','82228008.0','87326000.0','90176007.0','90979004.0','95885008.0','102453009.0','109362006.0','111277007.0','111816002.0','111816002.0','126664009.0','164260005.0','186659004.0','186675001.0','186963008.0','195655000.0','195655000.0','195656004.0','195657008.0','195658003.0','195659006.0','195660001.0','195662009.0','195662009.0','195663004.0','195666007.0','195667003.0','195668008.0','195669000.0','195670004.0','195671000.0','195672007.0','195673002.0','195676005.0','195677001.0','195707008.0','195779005.0','195780008.0','195782000.0','195798007.0','195803003.0','195804009.0','195924009.0','232399005.0','232400003.0','232401004.0','232402006.0','232403001.0','232404007.0','232405008.0','232405008.0','232406009.0','232417005.0','232420002.0','234528007.0','240444009.0','240547000.0','300932000.0','302911003.0','312422001.0','363746003.0','399095008.0','405737000.0','415724006.0','J02','J02.0','J02.8','J02.9','J03','J03.0','J03.00','J03.01','J03.8','J03.80','J03.81','J03.9','J03.90','J03.91']},'2.16.840.1.113883.3.464.0001.385':{'RxNorm':['197511.0','197512.0','198044.0','198048.0','198049.0','198050.0','199370.0','199886.0','240639.0','240640.0','250095.0','259311.0','309304.0','309308.0','309309.0','309310.0','310445.0','311296.0','311364.0','311787.0','313522.0','313523.0','314009.0','315065.0','351156.0','359383.0','403921.0','477391.0','597446.0','637560.0','644541.0','794769.0','877486.0']},'2.16.840.1.113883.3.464.0001.397':{'RxNorm':['105189','197449','197452','197453','197898','197899','204929','245239','309040','309041','309042','309043','309044','309045','309080','309081','309095','309096','309097','309098','309099','309100','309101','309103','311370','311371','313888','313926','349507','349508','387065','387066','476322','476325','476327','476623']},'2.16.840.1.113883.3.464.0001.406':{'RxNorm':['142118.0','198334.0','198335.0','313137.0','648254.0','686383.0','894883.0','198235','198420','246252','312340','313134','315219','413716','756189']},'2.16.840.1.113883.3.464.0001.408':{'RxNorm':['105220','105227','197633','197984','197985','198249','198250','198252','199026','199027','207362','207364','242807','242814','283535','310026','310027','310028','310029','310030','313251','313252','313253','313254','314108','317127','348869','348870','349114','349115','349116','351121','359465','403840','406524','434018','597520','597521','597808','629695','629697','629699','630819','630824','630827','643821','645613','645614','645619','647109','687231','700408','705861','728207','756134','756192','799048','858062','858065','858372','858375']},'2.16.840.1.113883.3.464.0001.409':{'RxNorm':['197450','197451','200346','204871','250156','309054','309058','309076','309077','309078','309079','309085','309086','309087','309090','309091','309092','309093','351127','419849','476576','562619','645956','746671','847360']}};\n // Measure variables\nvar MeasurePeriod = {\n \"low\": new TS(\"20100101\", null, true),\n \"high\": new TS(\"20110101\", null, true)\n}\nhqmfjs.MeasurePeriod = function(patient) {\n return [new hQuery.CodedEntry(\n {\n \"start_time\": MeasurePeriod.low.asDate().getTime()/1000,\n \"end_time\": MeasurePeriod.high.asDate().getTime()/1000,\n \"codes\": {}\n }\n )];\n}\nif (typeof effective_date === 'number') {\n MeasurePeriod.high.date = new Date(1000*effective_date);\n MeasurePeriod.low.date = new Date(1000*effective_date);\n MeasurePeriod.low.date.setFullYear(MeasurePeriod.low.date.getFullYear()-1);\n}\n\n// Data critera\nhqmfjs.MedicationDispensedPharyngitisAntibiotics_precondition_4 = function(patient) {\n var events = patient.allMedications();\n events = events.withStatuses([\"dispensed\"]);\n events = events.withoutNegation();\n var codes = getCodes(\"2.16.840.1.113883.3.464.0001.373\");\n var start = null;\n var end = null;\n events = events.match(codes, start, end, true);\n\n events.specificContext=Specifics.identity()\n return events;\n}\n\nhqmfjs.MedicationOrderPharyngitisAntibiotics_precondition_6 = function(patient) {\n var events = patient.allMedications();\n events = events.withStatuses([\"ordered\"]);\n events = events.withoutNegation();\n var codes = getCodes(\"2.16.840.1.113883.3.464.0001.373\");\n var start = null;\n var end = null;\n events = events.match(codes, start, end, true);\n\n events.specificContext=Specifics.identity()\n return events;\n}\n\nhqmfjs.MedicationActivePharyngitisAntibiotics_precondition_8 = function(patient) {\n var events = patient.allMedications();\n events = events.withStatuses([\"active\"]);\n events = events.withoutNegation();\n var codes = getCodes(\"2.16.840.1.113883.3.464.0001.373\");\n var start = null;\n var end = null;\n events = events.match(codes, start, end, true);\n\n events.specificContext=Specifics.identity()\n return events;\n}\n\nhqmfjs.EncounterEncounterAmbulatoryIncludingPediatrics_precondition_1 = function(patient) {\n var events = patient.encounters();\n events = events.withoutNegation();\n var codes = getCodes(\"2.16.840.1.113883.3.464.0001.231\");\n var start = null;\n var end = null;\n events = events.match(codes, start, end, true);\n\n events = DURING(events, hqmfjs.MeasurePeriod(patient));\n events = SBS(events, hqmfjs.GROUP_SBS_CHILDREN_1(patient), new IVL_PQ(null, new PQ(3, \"d\", true)));\n return events;\n}\n\nhqmfjs.GROUP_SBS_CHILDREN_1 = function(patient) {\n var events = UNION(\n hqmfjs.MedicationDispensedPharyngitisAntibiotics_precondition_4(patient),\n hqmfjs.MedicationOrderPharyngitisAntibiotics_precondition_6(patient),\n hqmfjs.MedicationActivePharyngitisAntibiotics_precondition_8(patient)\n );\n\n events.specificContext=Specifics.identity()\n return events;\n}\n\nhqmfjs.LaboratoryTestPerformedGroupAStreptococcusTest_precondition_11 = function(patient) {\n var events = patient.laboratoryTests();\n events = events.withStatuses([\"performed\"]);\n events = events.withoutNegation();\n var codes = getCodes(\"2.16.840.1.113883.3.464.0001.250\");\n var start = null;\n var end = null;\n events = events.match(codes, start, end, true);\n\n events = SBE(events, hqmfjs.EncounterEncounterAmbulatoryIncludingPediatrics_precondition_1(patient), new IVL_PQ(null, new PQ(3, \"d\", true)));\n return events;\n}\n\nhqmfjs.MedicationDispensedPharyngitisAntibiotics_precondition_16 = function(patient) {\n var events = patient.allMedications();\n events = events.withStatuses([\"dispensed\"]);\n events = events.withoutNegation();\n var codes = getCodes(\"2.16.840.1.113883.3.464.0001.373\");\n var start = null;\n var end = null;\n events = events.match(codes, start, end, true);\n\n events.specificContext=Specifics.identity()\n return events;\n}\n\nhqmfjs.MedicationOrderPharyngitisAntibiotics_precondition_18 = function(patient) {\n var events = patient.allMedications();\n events = events.withStatuses([\"ordered\"]);\n events = events.withoutNegation();\n var codes = getCodes(\"2.16.840.1.113883.3.464.0001.373\");\n var start = null;\n var end = null;\n events = events.match(codes, start, end, true);\n\n events.specificContext=Specifics.identity()\n return events;\n}\n\nhqmfjs.MedicationActivePharyngitisAntibiotics_precondition_20 = function(patient) {\n var events = patient.allMedications();\n events = events.withStatuses([\"active\"]);\n events = events.withoutNegation();\n var codes = getCodes(\"2.16.840.1.113883.3.464.0001.373\");\n var start = null;\n var end = null;\n events = events.match(codes, start, end, true);\n\n events.specificContext=Specifics.identity()\n return events;\n}\n\nhqmfjs.EncounterEncounterAmbulatoryIncludingPediatrics_precondition_13 = function(patient) {\n var events = patient.encounters();\n events = events.withoutNegation();\n var codes = getCodes(\"2.16.840.1.113883.3.464.0001.231\");\n var start = null;\n var end = null;\n events = events.match(codes, start, end, true);\n\n events = DURING(events, hqmfjs.MeasurePeriod(patient));\n events = SBS(events, hqmfjs.GROUP_SBS_CHILDREN_2(patient), new IVL_PQ(null, new PQ(3, \"d\", true)));\n return events;\n}\n\nhqmfjs.GROUP_SBS_CHILDREN_2 = function(patient) {\n var events = UNION(\n hqmfjs.MedicationDispensedPharyngitisAntibiotics_precondition_16(patient),\n hqmfjs.MedicationOrderPharyngitisAntibiotics_precondition_18(patient),\n hqmfjs.MedicationActivePharyngitisAntibiotics_precondition_20(patient)\n );\n\n events.specificContext=Specifics.identity()\n return events;\n}\n\nhqmfjs.LaboratoryTestPerformedGroupAStreptococcusTest_precondition_23 = function(patient) {\n var events = patient.laboratoryTests();\n events = events.withStatuses([\"performed\"]);\n events = events.withoutNegation();\n var codes = getCodes(\"2.16.840.1.113883.3.464.0001.250\");\n var start = null;\n var end = null;\n events = events.match(codes, start, end, true);\n\n events = SAE(events, hqmfjs.EncounterEncounterAmbulatoryIncludingPediatrics_precondition_13(patient), new IVL_PQ(null, new PQ(3, \"d\", true)));\n return events;\n}\n\nhqmfjs.EncounterEncounterAmbulatoryIncludingPediatrics_precondition_26 = function(patient) {\n var events = patient.encounters();\n events = events.withoutNegation();\n var codes = getCodes(\"2.16.840.1.113883.3.464.0001.231\");\n var start = null;\n var end = null;\n events = events.match(codes, start, end, true);\n\n events = DURING(events, hqmfjs.MeasurePeriod(patient));\n return events;\n}\n\nhqmfjs.EncounterEncounterAmbulatoryIncludingPediatrics_precondition_28 = function(patient) {\n var events = patient.encounters();\n events = events.withoutNegation();\n var codes = getCodes(\"2.16.840.1.113883.3.464.0001.231\");\n var start = null;\n var end = null;\n events = events.match(codes, start, end, true);\n\n events = DURING(events, hqmfjs.MeasurePeriod(patient));\n return events;\n}\n\nhqmfjs.DiagnosisActivePharyngitis_precondition_29 = function(patient) {\n var events = patient.allProblems();\n events = events.withStatuses([\"active\"]);\n events = events.withoutNegation();\n var codes = getCodes(\"2.16.840.1.113883.3.464.0001.369\");\n var start = null;\n var end = null;\n events = events.match(codes, start, end, true);\n\n events = DURING(events, hqmfjs.EncounterEncounterAmbulatoryIncludingPediatrics_precondition_28(patient));\n return events;\n}\n\nhqmfjs.MedicationDispensedPharyngitisAntibiotics_precondition_34 = function(patient) {\n var events = patient.allMedications();\n events = events.withStatuses([\"dispensed\"]);\n events = events.withoutNegation();\n var codes = getCodes(\"2.16.840.1.113883.3.464.0001.373\");\n var start = null;\n var end = null;\n events = events.match(codes, start, end, true);\n\n events.specificContext=Specifics.identity()\n return events;\n}\n\nhqmfjs.MedicationOrderPharyngitisAntibiotics_precondition_36 = function(patient) {\n var events = patient.allMedications();\n events = events.withStatuses([\"ordered\"]);\n events = events.withoutNegation();\n var codes = getCodes(\"2.16.840.1.113883.3.464.0001.373\");\n var start = null;\n var end = null;\n events = events.match(codes, start, end, true);\n\n events.specificContext=Specifics.identity()\n return events;\n}\n\nhqmfjs.MedicationActivePharyngitisAntibiotics_precondition_38 = function(patient) {\n var events = patient.allMedications();\n events = events.withStatuses([\"active\"]);\n events = events.withoutNegation();\n var codes = getCodes(\"2.16.840.1.113883.3.464.0001.373\");\n var start = null;\n var end = null;\n events = events.match(codes, start, end, true);\n\n events.specificContext=Specifics.identity()\n return events;\n}\n\nhqmfjs.EncounterEncounterAmbulatoryIncludingPediatrics_precondition_31 = function(patient) {\n var events = patient.encounters();\n events = events.withoutNegation();\n var codes = getCodes(\"2.16.840.1.113883.3.464.0001.231\");\n var start = null;\n var end = null;\n events = events.match(codes, start, end, true);\n\n events = DURING(events, hqmfjs.MeasurePeriod(patient));\n events = SBS(events, hqmfjs.GROUP_SBS_CHILDREN_3(patient), new IVL_PQ(null, new PQ(3, \"d\", true)));\n return events;\n}\n\nhqmfjs.GROUP_SBS_CHILDREN_3 = function(patient) {\n var events = UNION(\n hqmfjs.MedicationDispensedPharyngitisAntibiotics_precondition_34(patient),\n hqmfjs.MedicationOrderPharyngitisAntibiotics_precondition_36(patient),\n hqmfjs.MedicationActivePharyngitisAntibiotics_precondition_38(patient)\n );\n\n events.specificContext=Specifics.identity()\n return events;\n}\n\nhqmfjs.EncounterEncounterAmbulatoryIncludingPediatrics_precondition_49 = function(patient) {\n var events = patient.encounters();\n events = events.withoutNegation();\n var codes = getCodes(\"2.16.840.1.113883.3.464.0001.231\");\n var start = null;\n var end = null;\n events = events.match(codes, start, end, true);\n\n events = DURING(events, hqmfjs.MeasurePeriod(patient));\n return events;\n}\n\nhqmfjs.MedicationDispensedPharyngitisAntibiotics_precondition_42 = function(patient) {\n var events = patient.allMedications();\n events = events.withStatuses([\"dispensed\"]);\n events = events.withoutNegation();\n var codes = getCodes(\"2.16.840.1.113883.3.464.0001.373\");\n var start = null;\n var end = null;\n events = events.match(codes, start, end, true);\n\n events = SBS(events, hqmfjs.EncounterEncounterAmbulatoryIncludingPediatrics_precondition_49(patient), new IVL_PQ(null, new PQ(30, \"d\", true)));\n return events;\n}\n\nhqmfjs.MedicationOrderPharyngitisAntibiotics_precondition_44 = function(patient) {\n var events = patient.allMedications();\n events = events.withStatuses([\"ordered\"]);\n events = events.withoutNegation();\n var codes = getCodes(\"2.16.840.1.113883.3.464.0001.373\");\n var start = null;\n var end = null;\n events = events.match(codes, start, end, true);\n\n events = SBS(events, hqmfjs.EncounterEncounterAmbulatoryIncludingPediatrics_precondition_49(patient), new IVL_PQ(null, new PQ(30, \"d\", true)));\n return events;\n}\n\nhqmfjs.MedicationActivePharyngitisAntibiotics_precondition_46 = function(patient) {\n var events = patient.allMedications();\n events = events.withStatuses([\"active\"]);\n events = events.withoutNegation();\n var codes = getCodes(\"2.16.840.1.113883.3.464.0001.373\");\n var start = null;\n var end = null;\n events = events.match(codes, start, end, true);\n\n events = SBS(events, hqmfjs.EncounterEncounterAmbulatoryIncludingPediatrics_precondition_49(patient), new IVL_PQ(null, new PQ(30, \"d\", true)));\n return events;\n}\n\nhqmfjs.PatientCharacteristicBirthDate_precondition_53 = function(patient) {\nvar value = patient.birthtime();\nvar events = [value];\nevents = SBS(events, hqmfjs.MeasurePeriod(patient), new IVL_PQ(new PQ(2, \"a\", true), null));\nevents.specificContext=Specifics.identity();\nreturn events;\n\n}\n\nhqmfjs.PatientCharacteristicBirthDate_precondition_55 = function(patient) {\nvar value = patient.birthtime();\nvar events = [value];\nevents = SBS(events, hqmfjs.MeasurePeriod(patient), new IVL_PQ(null, new PQ(17, \"a\", true)));\nevents.specificContext=Specifics.identity();\nreturn events;\n\n}\n\n\n\n // #########################\n // ##### MEASURE LOGIC #####\n // #########################\n \n hqmfjs.initializeSpecifics = function(patient_api, hqmfjs) { Specifics.initialize(patient_api,hqmfjs) }\n\n // INITIAL PATIENT POPULATION\n hqmfjs.IPP = function(patient) {\n return allTrue( \n allTrue( \n hqmfjs.PatientCharacteristicBirthDate_precondition_53(patient), \n hqmfjs.PatientCharacteristicBirthDate_precondition_55(patient)\n )\n );\n};\n\n\n // DENOMINATOR\n hqmfjs.DENOM = function(patient) {\n return allTrue( \n allTrue( \n hqmfjs.EncounterEncounterAmbulatoryIncludingPediatrics_precondition_26(patient), \n hqmfjs.DiagnosisActivePharyngitis_precondition_29(patient), \n atLeastOneTrue( \n hqmfjs.EncounterEncounterAmbulatoryIncludingPediatrics_precondition_31(patient)\n ), \n atLeastOneFalse( \n atLeastOneTrue( \n hqmfjs.MedicationDispensedPharyngitisAntibiotics_precondition_42(patient), \n hqmfjs.MedicationOrderPharyngitisAntibiotics_precondition_44(patient), \n hqmfjs.MedicationActivePharyngitisAntibiotics_precondition_46(patient)\n )\n )\n )\n );\n};\n\n\n // NUMERATOR\n hqmfjs.NUMER = function(patient) {\n return allTrue( \n allTrue( \n hqmfjs.LaboratoryTestPerformedGroupAStreptococcusTest_precondition_11(patient), \n hqmfjs.LaboratoryTestPerformedGroupAStreptococcusTest_precondition_23(patient)\n )\n );\n};\n\n\n hqmfjs.EXCL = function(patient) { return new Boolean(false); }\n hqmfjs.DENEXCEP = function(patient) { return new Boolean(false); }\n \n\n hqmfjs.initializeSpecifics(patient_api, hqmfjs)\n \n var population = function() {\n return executeIfAvailable(hqmfjs.IPP, patient_api);\n }\n var denominator = function() {\n return executeIfAvailable(hqmfjs.DENOM, patient_api);\n }\n var numerator = function() {\n return executeIfAvailable(hqmfjs.NUMER, patient_api);\n }\n var exclusion = function() {\n return executeIfAvailable(hqmfjs.EXCL, patient_api);\n }\n var denexcep = function() {\n return executeIfAvailable(hqmfjs.DENEXCEP, patient_api);\n }\n \n var executeIfAvailable = function(optionalFunction, arg) {\n if (typeof(optionalFunction)==='function')\n return optionalFunction(arg);\n else\n return false;\n }\n\n if (Logger.enabled) enableMeasureLogging(hqmfjs);\n\n map(patient, population, denominator, numerator, exclusion, denexcep);\n \n };\n ",
625
625
  "measure": {
626
626
  "encounter_encounter_ambulatory_including_pediatrics": {
627
627
  "type": "array",
@@ -1,6 +1,7 @@
1
1
  {
2
2
 
3
3
  "id": "0043",
4
+ "nqf_id" : "0043",
4
5
  "name": "Pneumonia Vaccination Status for Older Adults",
5
6
  "description": "Patients more than 65 years old who received a pneumococcal vaccine.",
6
7
  "category": "Miscellaneous",
data/test/mongoid.yml ADDED
@@ -0,0 +1,6 @@
1
+ test:
2
+ sessions:
3
+ default:
4
+ database: test
5
+ hosts:
6
+ - localhost:27017
data/test/test_helper.rb CHANGED
@@ -3,17 +3,13 @@ require 'minitest/autorun'
3
3
  require 'quality-measure-engine'
4
4
  require 'test/unit'
5
5
  require 'turn'
6
-
7
- db_host = ENV['TEST_DB_HOST'] || 'localhost'
8
-
9
- Mongoid.configure do |config|
10
- config.sessions = { default: { hosts: [ "#{db_host}:27017" ], database: 'test' }}
11
- end
6
+ require 'pry-nav'
7
+ Mongoid.load!(File.join(File.dirname(__FILE__),"mongoid.yml"), :test)
12
8
 
13
9
  class MiniTest::Unit::TestCase
14
10
 
15
11
  def load_system_js
16
- Mongoid.default_session['system.js'].find.remove_all
12
+ Mongoid.default_session['system.js'].find.remove_all
17
13
  Dir.glob(File.join(File.dirname(__FILE__), 'fixtures', "library_functions", '*.js')).each do |json_fixture_file|
18
14
  name = File.basename(json_fixture_file,".*")
19
15
  fn = "function () {\n #{File.read(json_fixture_file)} \n }"
@@ -4,8 +4,8 @@ class MapReduceBuilderTest < MiniTest::Unit::TestCase
4
4
  include QME::DatabaseAccess
5
5
 
6
6
  def setup
7
- raw_measure_json = File.read(File.join('test', 'fixtures', 'measures', 'measure_metadata.json'))
8
- @measure_json = JSON.parse(raw_measure_json)
7
+ collection_fixtures(get_db(), 'measures')
8
+ @measure_json = QME::QualityMeasure.where({"nqf_id" => '0043'}).first
9
9
  load_system_js
10
10
  end
11
11
 
@@ -10,12 +10,15 @@ class MapReduceExecutorTest < MiniTest::Unit::TestCase
10
10
  collection_fixtures(get_db(), 'measures')
11
11
  collection_fixtures(get_db(), 'records', '_id')
12
12
  collection_fixtures(get_db(), 'bundles')
13
+ options = {'measure_id' => "2E679CD2-3FEC-4A75-A75A-61403E5EFEE8",
14
+ 'effective_date' => Time.gm(2011, 1, 15).to_i}
15
+ @quality_report =QME::QualityReport.find_or_create_by(options)
13
16
  load_system_js
14
17
  end
15
18
 
16
19
  def test_map_records_into_measure_groups
17
- executor = QME::MapReduce::Executor.new("2E679CD2-3FEC-4A75-A75A-61403E5EFEE8", nil,
18
- 'effective_date' => Time.gm(2011, 1, 15).to_i)
20
+ executor = QME::MapReduce::Executor.new(@quality_report.measure_id,@quality_report.sub_id, {
21
+ 'effective_date' => Time.gm(2011, 1, 15).to_i})
19
22
 
20
23
  executor.map_records_into_measure_groups
21
24
 
@@ -29,14 +32,14 @@ class MapReduceExecutorTest < MiniTest::Unit::TestCase
29
32
 
30
33
 
31
34
  def test_calculate_supplemental_data_elements
32
- executor = QME::MapReduce::Executor.new("2E679CD2-3FEC-4A75-A75A-61403E5EFEE8", nil,
33
- 'effective_date' => Time.gm(2011, 1, 15).to_i)
35
+ executor = QME::MapReduce::Executor.new(@quality_report.measure_id,@quality_report.sub_id, {
36
+ 'effective_date' => Time.gm(2011, 1, 15).to_i})
34
37
 
35
38
  executor.map_records_into_measure_groups
36
- executor.count_records_in_measure_groups
37
- assert_equal 1, get_db['query_cache'].find().count
38
- doc = get_db['query_cache'].find().first
39
- suppl = doc["supplemental_data"]
39
+ result = executor.count_records_in_measure_groups
40
+
41
+ suppl = result["supplemental_data"]
42
+
40
43
  assert !suppl.empty?, "should contain supplemental data entries"
41
44
  ipp = {QME::QualityReport::RACE =>{"UNK"=>2, "1002-5"=>1},
42
45
  QME::QualityReport::ETHNICITY => {"UNK"=>1, "2186-5"=>2},
@@ -66,46 +69,32 @@ class MapReduceExecutorTest < MiniTest::Unit::TestCase
66
69
  end
67
70
 
68
71
  def test_count_records_in_measure_groups
69
- executor = QME::MapReduce::Executor.new("2E679CD2-3FEC-4A75-A75A-61403E5EFEE8", nil,
70
- 'effective_date' => Time.gm(2011, 1, 15).to_i)
72
+ executor = QME::MapReduce::Executor.new(@quality_report.measure_id,@quality_report.sub_id, {
73
+ 'effective_date' => Time.gm(2011, 1, 15).to_i})
71
74
  executor.map_records_into_measure_groups
72
- executor.count_records_in_measure_groups
73
- assert_equal 1, get_db['query_cache'].find().count
74
- doc = get_db['query_cache'].find().first
75
- assert_equal 3, doc[QME::QualityReport::POPULATION]
76
- assert_equal 2, doc[QME::QualityReport::DENOMINATOR]
77
- assert_equal 1, doc[QME::QualityReport::NUMERATOR]
75
+ result = executor.count_records_in_measure_groups
76
+ assert_equal 3, result[QME::QualityReport::POPULATION]
77
+ assert_equal 2, result[QME::QualityReport::DENOMINATOR]
78
+ assert_equal 1, result[QME::QualityReport::NUMERATOR]
78
79
  end
79
80
 
80
81
  def test_map_record_into_measure_groups
81
- executor = QME::MapReduce::Executor.new("2E679CD2-3FEC-4A75-A75A-61403E5EFEE8", nil,
82
- 'effective_date' => Time.gm(2011, 1, 15).to_i)
82
+ executor = QME::MapReduce::Executor.new( @quality_report.measure_id,@quality_report.sub_id, {
83
+ 'effective_date' => Time.gm(2011, 1, 15).to_i})
83
84
  executor.map_record_into_measure_groups("12345")
84
85
 
85
- assert_equal 1, get_db['patient_cache'].find().count
86
- assert_equal 1, get_db['patient_cache'].find("value.#{QME::QualityReport::POPULATION}" => 1).count
87
- assert_equal 0, get_db['patient_cache'].find("value.#{QME::QualityReport::POPULATION}" => 0).count
88
- assert_equal 1, get_db['patient_cache'].find("value.#{QME::QualityReport::DENOMINATOR}" => 1).count
89
- assert_equal 1, get_db['patient_cache'].find("value.#{QME::QualityReport::NUMERATOR}" => 1).count
86
+ assert_equal 1, QME::PatientCache.count
87
+ assert_equal 1, QME::PatientCache.where("value.#{QME::QualityReport::POPULATION}" => 1).count
88
+ assert_equal 0, QME::PatientCache.where("value.#{QME::QualityReport::POPULATION}" => 0).count
89
+ assert_equal 1, QME::PatientCache.where("value.#{QME::QualityReport::DENOMINATOR}" => 1).count
90
+ assert_equal 1, QME::PatientCache.where("value.#{QME::QualityReport::NUMERATOR}" => 1).count
90
91
  end
91
92
 
92
93
  def test_get_patient_result
93
- executor = QME::MapReduce::Executor.new("2E679CD2-3FEC-4A75-A75A-61403E5EFEE8", nil,
94
- 'effective_date' => Time.gm(2011, 1, 15).to_i)
95
- result = executor.get_patient_result("12345")
96
- assert_equal 0, get_db['patient_cache'].find().count
97
- assert result[QME::QualityReport::NUMERATOR]
98
- end
99
-
100
- def test_get_patient_result_with_bundle_id
101
- measure_id = "2E679CD2-3FEC-4A75-A75A-61403E5EFEE8"
102
- bundle_id = get_db()['bundles'].find.first
103
- get_db()['measures'].find('id' => measure_id).update(:$set => {'bundle_id' => bundle_id})
104
- executor = QME::MapReduce::Executor.new(measure_id, nil,
105
- 'effective_date' => Time.gm(2011, 1, 15).to_i, 'bundle_id' => bundle_id)
94
+ executor = QME::MapReduce::Executor.new(@quality_report.measure_id,@quality_report.sub_id, {
95
+ 'effective_date' => Time.gm(2011, 1, 15).to_i})
106
96
  result = executor.get_patient_result("12345")
107
- assert_equal 0, get_db['patient_cache'].find().count
97
+ assert_equal 0, QME::PatientCache.count
108
98
  assert result[QME::QualityReport::NUMERATOR]
109
99
  end
110
-
111
100
  end
@@ -17,8 +17,8 @@ class MapCalculationJobTest < MiniTest::Unit::TestCase
17
17
  def test_perform
18
18
  options = {'measure_id' => "2E679CD2-3FEC-4A75-A75A-61403E5EFEE8",
19
19
  'effective_date' => Time.gm(2011, 1, 15).to_i}
20
-
21
- job = Delayed::Job.enqueue(QME::MapReduce::MeasureCalculationJob.new(options))
20
+ qr = QME::QualityReport.find_or_create_by(options)
21
+ job = Delayed::Job.enqueue(QME::MapReduce::MeasureCalculationJob.new({'quality_report_id' => qr.id,"oid_dictionary"=>{}}))
22
22
  assert job
23
23
  end
24
24
  end