Skip to content

Commit

Permalink
Risk assessment results now function as get request with params, closes
Browse files Browse the repository at this point in the history
  • Loading branch information
krand7 committed Apr 10, 2015
1 parent af69bfc commit d167e93
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
4 changes: 4 additions & 0 deletions app/controllers/tools_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ def risk_assessment_results
@is_male = params[:gender] == 'male'
@bang_score = (@bmi > 35 ? 1 : 0) + (params[:age].to_i > 50 ? 1 : 0) + (@has_large_neck ? 1 : 0) + (@is_male ? 1 : 0)
@risk_category = riskCategory(@stop_score, @stop_score + @bang_score, @has_large_neck, @is_male, @bmi > 35)
redirect_to sleep_apnea_risk_assessment_results_path(category: @risk_category, score: @stop_score+@bang_score)
end

def risk_assessment_results_display
end

def calculateBMI
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
- risk_multipliers = [0, 0, 0, 250, 300, 500, 600, 700, 700]
- @risk_category = params[:category].to_i

#risk-assessment-results-container
.row.reset-layout.logo-color-bcg{ style: 'padding-bottom:10px;' }
Expand Down Expand Up @@ -27,7 +27,7 @@
%h2.f300
Your risk score is:
%br
%span.f500.primary-orange= @stop_score + @bang_score
%span.f500.primary-orange= params[:score]
- if @risk_category == 1
%p.lead
You're currently at a low risk for developing sleep apnea. However, your risk can increase with age and with body weight. We encourage you to maintain a healthy diet and stay active to help keep your risk low!
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
## Public Tools
get 'sleep-apnea-risk-assessment' => 'tools#risk_assessment'
post 'sleep-apnea-risk-assessment/results' => 'tools#risk_assessment_results'
get 'sleep-apnea-risk-assessment/results' => 'tools#risk_assessment_results_display'
# Tools
get 'sleep-apnea-and-bmi' => 'tools#bmi_ahi'

Expand Down
4 changes: 2 additions & 2 deletions test/controllers/tools_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ def test_risk_assessment
end

test "should get risk assessment results" do
post :risk_assessment_results
assert_response :success
get :risk_assessment_results
assert_redirected_to sleep_apnea_risk_assessment_results_path(category: 1, score: 0)
end

end

0 comments on commit d167e93

Please sign in to comment.