From 42ea46352fb9ee2526f7ec99cf3e67373e9f5845 Mon Sep 17 00:00:00 2001 From: David Czulada Date: Tue, 30 Jul 2024 10:21:25 -0400 Subject: [PATCH] Make sure RV and SDE calculations are not impacted by randomazation --- lib/validators/calculating_augmented_records.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/validators/calculating_augmented_records.rb b/lib/validators/calculating_augmented_records.rb index 85ae8f105..5bdccb0bf 100644 --- a/lib/validators/calculating_augmented_records.rb +++ b/lib/validators/calculating_augmented_records.rb @@ -33,15 +33,17 @@ def validate_calculated_results(rec, options) def compare_results(results, record, options) passed = true + sde_passed = true @measures.each do |measure| # compare results to patient as it was initially calculated for product test (use original product patient id before cloning) orig_results = CQM::IndividualResult.where(patient_id: options[:orig_product_patient].id, measure_id: measure.id) orig_results.each do |orig_result| new_result = results.select do |arr| - arr.measure_id == measure.id.to_s && - arr.patient_id == record.id.to_s && - arr.population_set_key == orig_result['population_set_key'] + arr.measure_id == measure.id.to_s && arr.patient_id == record.id.to_s && arr.population_set_key == orig_result['population_set_key'] end.first + issue_list = [] + orig_result.compare_sde_results(new_result, issue_list) + sde_passed = issue_list.blank? measure.population_keys.each do |pop_id| if orig_result[pop_id] != new_result[pop_id] passed = false @@ -50,7 +52,7 @@ def compare_results(results, record, options) end end end - passed + passed && sde_passed end end end