From 51632aba83ccbe7b40d576449e793b0ca8da39ea Mon Sep 17 00:00:00 2001 From: Piotr Mankowski Date: Fri, 10 Apr 2015 11:45:51 -0400 Subject: [PATCH] Fixed naming errors for my-sleep-apnea-treatment report, closing #539 --- app/models/surveys/report.rb | 9 ++++++--- lib/data/myapnea/surveys/my-sleep-apnea-treatment.yml | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/models/surveys/report.rb b/app/models/surveys/report.rb index 19cef01ca..04f3a17f5 100644 --- a/app/models/surveys/report.rb +++ b/app/models/surveys/report.rb @@ -231,20 +231,23 @@ def self.treatment_stats(encounter, value) 8 => 'satisfaction_with_tongue_stimulation', 9 => 'satisfaction_with_tonsillectomy', 10 => 'satisfaction_with_uppp', - 11 => 'satisfaction_with_nasal_deviation_surgery', - 12 => 'satisfaction_with_toungue_surgery', + 11 => 'satisfaction_with_naval_deviation', + 12 => 'satisfaction_with_tongue_surgery', 13 => 'satisfaction_with_jaw_surgery', 14 => 'satisfaction_with_bariatric_surgery' } + template_name = current_to_satisfaction_map[value] + puts template_name + # For each treatment (or top 5?) we want all the answer sessions where people indicated a not-6 for that answer_template (satisfaction) # Now, for this set of people, we want to find ratings for how the treatment helpled. # so, let's do it for CPAP base_query = Report.where(answer_template_name: template_name, encounter: encounter, locked: true) - values = base_query.where.not(value: nil).pluck(:value) + values = base_query.where.not(value: nil).pluck(:value) satisfaction_percent = values.select{|v| %(3 4).include?(v)}.length.to_f/values.length * 100.0 used_treatment = base_query.where.not(value: ['5', '6']).pluck(:answer_session_id) used_treatment_percent = (used_treatment.length.to_f/base_query.count.to_f) * 100.0 diff --git a/lib/data/myapnea/surveys/my-sleep-apnea-treatment.yml b/lib/data/myapnea/surveys/my-sleep-apnea-treatment.yml index 96a94555b..46d1025c5 100644 --- a/lib/data/myapnea/surveys/my-sleep-apnea-treatment.yml +++ b/lib/data/myapnea/surveys/my-sleep-apnea-treatment.yml @@ -388,7 +388,7 @@ questions: display_class: option-of-multiple option-of-6 survey-scale - name: satisfaction_with_naval_deviation data_type: answer_option_id - text: Naval deviation surgery + text: Nasal deviation surgery answer_options: - slug: satisfaction-with-naval-deviation-1 text: Very dissatisfied