diff --git a/framingham10yr/framingham10yr.py b/framingham10yr/framingham10yr.py index c4ca972..dbb978a 100644 --- a/framingham10yr/framingham10yr.py +++ b/framingham10yr/framingham10yr.py @@ -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 @@ -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 " - print "Example: framingham.py male 25 152 56 130 0 0" + print ("All values are required.") + print ("Usage: framingham.py ") + print ("Example: framingham.py male 25 152 56 130 0 0") exit(1) try: @@ -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()) \ No newline at end of file