Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
# @Param: Patient object
# @Output: Biomarker score
def obesity(Patient):
"""Calculate the BMI CVH score"""
if Patient.bmi < 25:
bmi_score = 2
elif Patient.bmi >= 25 and Patient.bmi < 30:
bmi_score = 1
else:
bmi_score = 0
return bmi_score
# @Param: Patient object
# @Output: Biomarker score
def dyslipidemia(Patient):
"""Calculate the cholesterol CVH score"""
# Patient not on lipid lowering medication
if Patient.lipid_lowering_med == False:
if (Patient.ldl_c < 100 or (Patient.total_cholesterol!= None and Patient.total_cholesterol < 170)):
cholesterol_score = 2
elif (Patient.ldl_c >= 100 and Patient.ldl_c < 159) or (Patient.total_cholesterol >= 170 and Patient.total_cholesterol < 199):
cholesterol_score = 1
else:
cholesterol_score = 0
# Patient is on lipid lowering medication
elif Patient.lipid_lowering_med == True:
if (Patient.ldl_c < 100 or Patient.total_cholesterol < 200):
cholesterol_score = 1
else:
cholesterol_score = 0
return cholesterol_score
# @Param: Patient object
# @Output: Biomarker score
def diabetes(Patient):
"""Calculate the fasting glucose CVH score"""
# Patient is not on diabetes medication
if Patient.diabetes_med == False:
if Patient.fasting_glucose < 100:
fasting_glucose_score = 2
elif Patient.fasting_glucose >= 100 and Patient.fasting_glucose < 125:
fasting_glucose_score = 1
else:
fasting_glucose_score = 0
# Patient is on diabetes medication
elif Patient.diabetes_med == True:
if Patient.fasting_glucose < 126:
fasting_glucose_score = 1
else:
fasting_glucose_score = 0
return fasting_glucose_score
# @Param: Patient object
# @Output: Biomarker score
def hypertension(Patient):
"""Calculate the blood pressure CVH score"""
# Patient is not on blood pressure medication
if Patient.blood_pressure_med == False:
if Patient.systolic_bp < 120 and Patient.diastolic_bp < 80:
bp_score = 2
elif (Patient.systolic_bp >= 120 and Patient.systolic_bp <= 129) and Patient.diastolic_bp < 80:
bp_score = 1
else:
bp_score = 0
# Patient is on blood pressure medication
elif Patient.blood_pressure_med == True:
if Patient.systolic_bp < 130 and Patient.diastolic_bp < 80:
bp_score = 1
else:
bp_score = 0
return bp_score
# @Param: Patient object
# @Output: List of Keys
def set_most_limiting_cvd(Patient):
"""Calculates CVD scores and sets corresponding bools in the database. Returns a list of most limiting risk factors."""
biomarkers = {"Obesity": obesity(Patient), "Dyslipidemia": dyslipidemia(Patient), "Hypertension": hypertension(Patient), "Diabetes": diabetes(Patient)}
min_score = min(biomarkers.values())
new_biomarkers = {k: v for k, v in biomarkers.items() if v == min_score}
if "Obesity" in new_biomarkers:
Patient.obesity_cvd = True
if "Dyslipidemia" in new_biomarkers:
Patient.dyslipidemia_cvd = True
if "Hypertension" in new_biomarkers:
Patient.hypertension_cvd = True
if "Diabetes" in new_biomarkers:
Patient.diabetes_cvd = True
Patient.biomarkers = [*new_biomarkers]
return [*new_biomarkers]
# @Param: Patient Object
# @Output: Integer
def total_cvd_risk_factors(Patient):
""" Calculate and return total risk factors based on table 5 of Optimize """
total_cvd_risk_factors = 0
risklist = []
if (Patient.age > 44 and Patient.sex == 0) or (Patient.age > 54 and Patient.sex == 1):
risklist.append("Age")
total_cvd_risk_factors += 1
if Patient.family_history == True:
risklist.append("Family History")
total_cvd_risk_factors += 1
if Patient.smoker == True:
risklist.append("Smoker")
total_cvd_risk_factors += 1
if Patient.regular_exercise == False:
risklist.append("sedentary")
total_cvd_risk_factors += 1
if Patient.obesity_cvd == True:
risklist.append("obese")
total_cvd_risk_factors +=1
if Patient.hypertension_cvd == True:
risklist.append("hypertension")
total_cvd_risk_factors +=1
if Patient.dyslipidemia_cvd == True:
risklist.append("dyslipidemia")
total_cvd_risk_factors +=1
if Patient.diabetes_cvd == True:
risklist.append("Diabetes")
total_cvd_risk_factors +=1
if Patient.hdl_c >= 60:
total_cvd_risk_factors -=1
print("Negative Risk Factor: hdl_c")
print(risklist)
Patient.total_cvd_risk_factor_score = total_cvd_risk_factors
return total_cvd_risk_factors