Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 20 additions & 15 deletions framingham10yr/framingham10yr.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,16 +457,21 @@ def framingham_10year_risk(sex, age, total_cholesterol, hdl_cholesterol,
response['errors']=errors
else:
response['points']=points








response['percent_risk']= percent_risk

without_perc = percent_risk.replace('%', '')
if '>' in without_perc:
modifier = 'gt'
without_perc = without_perc.replace('>', '')
elif '<' in without_perc:
modifier = 'lt'
without_perc = without_perc.replace('<', '')
else:
modifier = 'eq'

num_risk = int(without_perc)
response['num_risk'] = num_risk
response['modifier'] = modifier

return response


Expand All @@ -485,9 +490,9 @@ def framingham_10year_risk(sex, age, total_cholesterol, hdl_cholesterol,
blood_pressure_med_treatment=sys.argv[7].lower()

except(IndexError):
print "All values are required."
print "Usage: framingham.py <sex> <age> <total_cholesterol> <hdl_cholesterol systolic_blood_pressure> <smoker> <blood_pressure_med_treatment>"
print "Example: framingham.py male 25 152 56 130 0 0"
print ("All values are required.")
print ("Usage: framingham.py <sex> <age> <total_cholesterol> <hdl_cholesterol systolic_blood_pressure> <smoker> <blood_pressure_med_treatment>")
print ("Example: framingham.py male 25 152 56 130 0 0")
exit(1)

try:
Expand All @@ -498,9 +503,9 @@ def framingham_10year_risk(sex, age, total_cholesterol, hdl_cholesterol,
smoker, blood_pressure_med_treatment)

#return pretty-print json to standard out
print json.dumps(result, indent=4)
print (json.dumps(result, indent=4))

except():
print "An unexpected error occured. Here is the post-mortem:"
print sys.exc_info()
print( "An unexpected error occured. Here is the post-mortem:")
print( sys.exc_info())