diff --git a/lib/cypress/expected_results_calculator.rb b/lib/cypress/expected_results_calculator.rb index aca98b60..1971e537 100644 --- a/lib/cypress/expected_results_calculator.rb +++ b/lib/cypress/expected_results_calculator.rb @@ -52,7 +52,7 @@ def aggregate_results_for_measures(measures, individual_results = nil) # If individual_results are provided, use the results for the measure being aggregated measure_individual_results = individual_results.select { |res| res['measure_id'] == measure.id.to_s } if individual_results # If individual_results are provided, use them. Otherwise, look them up in the database by measure id and correlation_id - measure_individual_results ||= CQM::IndividualResult.where('measure_id' => measure._id, correlation_id: @correlation_id) + measure_individual_results ||= CQM::IndividualResult.where('measure_id' => measure._id, correlation_id: @correlation_id, 'extendedData.manual_exclusion': {'$in': [nil, false]}) aggregate_results_for_measure(measure, measure_individual_results) end @@ -62,7 +62,7 @@ def aggregate_results_for_measures(measures, individual_results = nil) def aggregate_results_for_measure(measure, individual_results = nil) # If individual_results are provided, use them. Otherwise, look them up in the database by measure id and correlation_id begin - individual_results ||= CQM::IndividualResult.where('measure_id' => measure._id, correlation_id: @correlation_id) + individual_results ||= CQM::IndividualResult.where('measure_id' => measure._id, correlation_id: @correlation_id, 'extendedData.manual_exclusion': {'$in': [nil, false]}) rescue Exception => e Delayed::Worker.logger.info(e.message) Delayed::Worker.logger.info(e.backtrace.inspect) @@ -172,7 +172,7 @@ def create_query_cache_object(result, measure) if population_set.stratifications.length > 0 population_set.stratifications.each do |stratification| sub_id = stratification.stratification_id - qco = result[measure.hqmf_id] + qco = result[measure.hqmf_id].clone qco_saved = nil qco['result'] = {} if qco[sub_id].present? @@ -196,7 +196,7 @@ def create_query_cache_object(result, measure) # if there are only multiple populations but not stratifications else sub_id = population_set.population_set_id - qco = result[measure.hqmf_id] + qco = result[measure.hqmf_id].clone qco_saved = nil qco['result'] = {} if qco[sub_id].present? @@ -222,7 +222,7 @@ def create_query_cache_object(result, measure) elsif measure.population_sets.length == 1 && measure.population_sets[0].stratifications.length > 0 measure.population_sets[0].stratifications.each do |stratification| sub_id = stratification.stratification_id - qco = result[measure.hqmf_id] + qco = result[measure.hqmf_id].clone qco_saved = nil qco['result'] = {} if qco[sub_id].present?