 get_bmi = (height, weight) ->
   Math.round((weight / (height ** 2)) * 703)
 
-minimum_healthy_weight = (height) ->
-  Math.round(25 * (height ** 2) / 703)
+minimum_healthy_weight = (height, bmi) ->
+  desired_bmi = calculate_desired_BMI(bmi)
+  if desired_bmi==bmi
+    return parseFloat($("#my-weight").val())
+  else
+    Math.round(desired_bmi * (height ** 2) / 703)
 
 calculate_scatter_position = () ->
   old_w = parseFloat($("#my-weight").val())

  $("#ahi").removeClass "hidden"
  draw_ahi_graph2(x)


draw_bmi_graph = () ->
  data = [

  # If all data is entered, show the BMI graph, the AHI graph,
  # and autocomplete necessary weight for healthy BMI (if applicable)
  if feet_updated and inches_updated and current_weight_updated
    output_BMI()
  return get_bmi(height,weight)

output_BMI = () ->
  $('#bmi-graph svg.chart').html("")
  draw_bmi_graph()
  $("#bmi-ahi-results-container").removeClass "hidden"

weight_vs_ahi = (old_weight, new_weight) ->
  weight_change = ((new_weight-old_weight)/old_weight) * 100
