Skip to content

Commit

Permalink
Fixed naming errors for my-sleep-apnea-treatment report, closing #539
Browse files Browse the repository at this point in the history
  • Loading branch information
pmanko committed Apr 10, 2015
1 parent 38a50b6 commit 51632ab
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions app/models/surveys/report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/data/myapnea/surveys/my-sleep-apnea-treatment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 51632ab

Please sign in to comment.