diff --git a/health_calc.py b/health_calc.py index 15b4369..f4743e0 100755 --- a/health_calc.py +++ b/health_calc.py @@ -167,12 +167,29 @@ def height_age(band, gender, age): - (2.25382)*(age**2) \ + (7.31667)*(age) \ + 54. - else: + elif age <= 60: w = (-5.42535)*(10**-6)*(age**4) \ + (0.000921103)*(age**3) \ - (0.0606771)*(age**2) \ + (2.52153)*(age) \ + 57.5 + elif age <= 156: + w = (-1.21268*10**-10*age**7) \ + + (8.84224*10**-8*age**6) \ + - (0.0000272657*age**5) \ + + (0.00460575*age**4) \ + - (0.459965*age**3) \ + + (27.1377*age**2) \ + - (874.633*age) \ + + (11976.1) + else: + w = (-1.49603*10**-21*age**5) \ + + (1.3325*10**-18*age**4) \ + + (0.0000578704*age**3) \ + - (0.0381944*age**2) \ + + (8.46667*age) \ + - (442.) + elif band == -2: if age <= 12: w = (age**6)/5120 \ @@ -182,13 +199,48 @@ def height_age(band, gender, age): + (307)*(age**2)/160 \ + (143)*(age)/60 \ + 46 - else: + elif age <= 60: w = (-2.00939)*(10**-6)*(age**4) \ + (0.000385802)*(age**3) \ - (0.0292245)*(age**2) \ + (1.54861)*(age) \ + 56. + elif age <= 156: + w = (-2.29799*10**-10*age**7) \ + + (1.66984*10**-7*age**6) \ + - (0.0000513287*age**5) \ + + (0.00864673*age**4) \ + - (0.861622*age**3) \ + + (50.7566*age**2) \ + - (1635.17*age) \ + + (22302.5) + else: + w = (1.33959*10**-7*age**5) \ + - (0.000122975*age**4) \ + + (0.0449653*age**3) \ + - (8.19132*age**2) \ + + (744.347*age) \ + - (26884.) # band == -3 + elif band == 3: + if age <= 12: + elif age <= 60: + elif age <= 156: + w = (-1.32896*10**-10*age**7) \ + + (9.32598*10**-8*age**6) \ + - (0.0000276375*age**5) \ + + (0.00448211*age**4) \ + - (0.429503*age**3) \ + + (24.3144*age**2) \ + - (752.203*age) \ + + (9914.) + else: + w = (-2.84663*10**-7*age**5) \ + + (0.000264235*age**4) \ + - (0.0977165*age**3) \ + + (17.9897*age**2) \ + - (1647.88*age) \ + + (60224.5) else: if age <= 12: w = (0.0000868056)*(age**6) \ @@ -198,12 +250,28 @@ def height_age(band, gender, age): + (0.380556)*(age**2) \ + (4)*(age) \ + 44. - else: + elif age <= 60: w = (-3.01408)*(10**-6)*(age**4) \ + (0.000506366)*(age**3) \ - (0.0342882)*(age**2) \ + (1.59375)*(age) \ + 53.5 + elif age <= 156: + w = (-7.86301*10**-11*age**7) \ + + (5.61884*10**-8*age**6) \ + - (0.0000169749*age**5) \ + + (0.00280946*age**4) \ + - (0.275046*age**3) \ + + (15.9234*age**2) \ + - (504.133*age) \ + + (6821.2) + else: + w = (2.84663*10**-7*age**5) \ + - (0.000252178*age**4) \ + + (0.0888431*age**3) \ + - (15.5626*age**2) \ + + (1356.22*age) \ + - (46931.5) # girls else: if band == 2: diff --git a/templates/form.html b/templates/form.html index 2125ee2..e76dd89 100644 --- a/templates/form.html +++ b/templates/form.html @@ -26,12 +26,12 @@

- +

- +
diff --git a/web.py b/web.py index 65fbbab..0004d28 100755 --- a/web.py +++ b/web.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 from flask import Flask, render_template, request, url_for -import health_calc as hcal +import csv_parser as hcal app = Flask(__name__) @@ -25,9 +25,9 @@ def submit(): age_year = int(request.form['age_year']) age_month = int(request.form['age_month']) age = (12*age_year) + age_month - w_normal = hcal.is_weight_normal(gender, age, weight) - h_normal = hcal.is_height_normal(gender, age, height) - head_normal = hcal.is_head_normal(gender, age, hc) + w_normal = hcal.is_weight_age_normal(gender, weight, age) + h_normal = hcal.is_height_age_normal(gender, height, age) + head_normal = hcal.is_head_age_normal(gender, hc, age) print('W: {0}, H: {1}, HC: {2}, A: {3}'.format(weight, height, hc, age)) return render_template('submit.html', weight = w_normal,